· 7 years ago · Dec 17, 2018, 07:06 PM
1~/pmd-bin-6.10.0/bin ./run.sh cpd --minimum-tokens 100 --language c --files /home/shackle/pggit/postgresql | pbcopy
2
3Found a 200 line (1115 tokens) duplication in the following files:
4Starting at line 440 of /home/shackle/pggit/postgresql/src/backend/access/hash/hashfunc.c
5Starting at line 680 of /home/shackle/pggit/postgresql/src/backend/access/hash/hashfunc.c
6
7 if (((uintptr_t) k & UINT32_ALIGN_MASK) == 0)
8 {
9 /* Code path for aligned source data */
10 register const uint32 *ka = (const uint32 *) k;
11
12 /* handle most of the key */
13 while (len >= 12)
14 {
15 a += ka[0];
16 b += ka[1];
17 c += ka[2];
18 mix(a, b, c);
19 ka += 3;
20 len -= 12;
21 }
22
23 /* handle the last 11 bytes */
24 k = (const unsigned char *) ka;
25#ifdef WORDS_BIGENDIAN
26 switch (len)
27 {
28 case 11:
29 c += ((uint32) k[10] << 8);
30 /* fall through */
31 case 10:
32 c += ((uint32) k[9] << 16);
33 /* fall through */
34 case 9:
35 c += ((uint32) k[8] << 24);
36 /* fall through */
37 case 8:
38 /* the lowest byte of c is reserved for the length */
39 b += ka[1];
40 a += ka[0];
41 break;
42 case 7:
43 b += ((uint32) k[6] << 8);
44 /* fall through */
45 case 6:
46 b += ((uint32) k[5] << 16);
47 /* fall through */
48 case 5:
49 b += ((uint32) k[4] << 24);
50 /* fall through */
51 case 4:
52 a += ka[0];
53 break;
54 case 3:
55 a += ((uint32) k[2] << 8);
56 /* fall through */
57 case 2:
58 a += ((uint32) k[1] << 16);
59 /* fall through */
60 case 1:
61 a += ((uint32) k[0] << 24);
62 /* case 0: nothing left to add */
63 }
64#else /* !WORDS_BIGENDIAN */
65 switch (len)
66 {
67 case 11:
68 c += ((uint32) k[10] << 24);
69 /* fall through */
70 case 10:
71 c += ((uint32) k[9] << 16);
72 /* fall through */
73 case 9:
74 c += ((uint32) k[8] << 8);
75 /* fall through */
76 case 8:
77 /* the lowest byte of c is reserved for the length */
78 b += ka[1];
79 a += ka[0];
80 break;
81 case 7:
82 b += ((uint32) k[6] << 16);
83 /* fall through */
84 case 6:
85 b += ((uint32) k[5] << 8);
86 /* fall through */
87 case 5:
88 b += k[4];
89 /* fall through */
90 case 4:
91 a += ka[0];
92 break;
93 case 3:
94 a += ((uint32) k[2] << 16);
95 /* fall through */
96 case 2:
97 a += ((uint32) k[1] << 8);
98 /* fall through */
99 case 1:
100 a += k[0];
101 /* case 0: nothing left to add */
102 }
103#endif /* WORDS_BIGENDIAN */
104 }
105 else
106 {
107 /* Code path for non-aligned source data */
108
109 /* handle most of the key */
110 while (len >= 12)
111 {
112#ifdef WORDS_BIGENDIAN
113 a += (k[3] + ((uint32) k[2] << 8) + ((uint32) k[1] << 16) + ((uint32) k[0] << 24));
114 b += (k[7] + ((uint32) k[6] << 8) + ((uint32) k[5] << 16) + ((uint32) k[4] << 24));
115 c += (k[11] + ((uint32) k[10] << 8) + ((uint32) k[9] << 16) + ((uint32) k[8] << 24));
116#else /* !WORDS_BIGENDIAN */
117 a += (k[0] + ((uint32) k[1] << 8) + ((uint32) k[2] << 16) + ((uint32) k[3] << 24));
118 b += (k[4] + ((uint32) k[5] << 8) + ((uint32) k[6] << 16) + ((uint32) k[7] << 24));
119 c += (k[8] + ((uint32) k[9] << 8) + ((uint32) k[10] << 16) + ((uint32) k[11] << 24));
120#endif /* WORDS_BIGENDIAN */
121 mix(a, b, c);
122 k += 12;
123 len -= 12;
124 }
125
126 /* handle the last 11 bytes */
127#ifdef WORDS_BIGENDIAN
128 switch (len)
129 {
130 case 11:
131 c += ((uint32) k[10] << 8);
132 /* fall through */
133 case 10:
134 c += ((uint32) k[9] << 16);
135 /* fall through */
136 case 9:
137 c += ((uint32) k[8] << 24);
138 /* fall through */
139 case 8:
140 /* the lowest byte of c is reserved for the length */
141 b += k[7];
142 /* fall through */
143 case 7:
144 b += ((uint32) k[6] << 8);
145 /* fall through */
146 case 6:
147 b += ((uint32) k[5] << 16);
148 /* fall through */
149 case 5:
150 b += ((uint32) k[4] << 24);
151 /* fall through */
152 case 4:
153 a += k[3];
154 /* fall through */
155 case 3:
156 a += ((uint32) k[2] << 8);
157 /* fall through */
158 case 2:
159 a += ((uint32) k[1] << 16);
160 /* fall through */
161 case 1:
162 a += ((uint32) k[0] << 24);
163 /* case 0: nothing left to add */
164 }
165#else /* !WORDS_BIGENDIAN */
166 switch (len)
167 {
168 case 11:
169 c += ((uint32) k[10] << 24);
170 /* fall through */
171 case 10:
172 c += ((uint32) k[9] << 16);
173 /* fall through */
174 case 9:
175 c += ((uint32) k[8] << 8);
176 /* fall through */
177 case 8:
178 /* the lowest byte of c is reserved for the length */
179 b += ((uint32) k[7] << 24);
180 /* fall through */
181 case 7:
182 b += ((uint32) k[6] << 16);
183 /* fall through */
184 case 6:
185 b += ((uint32) k[5] << 8);
186 /* fall through */
187 case 5:
188 b += k[4];
189 /* fall through */
190 case 4:
191 a += ((uint32) k[3] << 24);
192 /* fall through */
193 case 3:
194 a += ((uint32) k[2] << 16);
195 /* fall through */
196 case 2:
197 a += ((uint32) k[1] << 8);
198 /* fall through */
199 case 1:
200 a += k[0];
201 /* case 0: nothing left to add */
202 }
203#endif /* WORDS_BIGENDIAN */
204 }
205
206 final(a, b, c);
207=====================================================================
208Found a 52 line (1050 tokens) duplication in the following files:
209Starting at line 107 of /home/shackle/pggit/postgresql/contrib/pgcrypto/crypt-des.c
210Starting at line 387 of /home/shackle/pggit/postgresql/src/port/crypt.c
211
212static uint8 sbox[8][64] = {
213 {
214 14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7,
215 0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8,
216 4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0,
217 15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13
218 },
219 {
220 15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10,
221 3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5,
222 0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15,
223 13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9
224 },
225 {
226 10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8,
227 13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1,
228 13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7,
229 1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12
230 },
231 {
232 7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15,
233 13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9,
234 10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4,
235 3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14
236 },
237 {
238 2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9,
239 14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6,
240 4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14,
241 11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3
242 },
243 {
244 12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11,
245 10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8,
246 9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6,
247 4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13
248 },
249 {
250 4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1,
251 13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6,
252 1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2,
253 6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12
254 },
255 {
256 13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7,
257 1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2,
258 7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8,
259 2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11
260 }
261};
262
263static uint8 un_pbox[32];
264=====================================================================
265Found a 120 line (1049 tokens) duplication in the following files:
266Starting at line 267 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/ecpglib/sqlda.c
267Starting at line 456 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/ecpglib/sqlda.c
268
269 offset = sqlda_compat_empty_size(res);
270
271 /*
272 * Set sqlvar[i]->sqldata pointers and convert values to correct format
273 */
274 for (i = 0; i < sqlda->sqld; i++)
275 {
276 int isnull;
277 int datalen;
278 bool set_data = true;
279
280 switch (sqlda->sqlvar[i].sqltype)
281 {
282 case ECPGt_short:
283 case ECPGt_unsigned_short:
284 ecpg_sqlda_align_add_size(offset, sizeof(short), sizeof(short), &offset, &next_offset);
285 sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
286 sqlda->sqlvar[i].sqllen = sizeof(short);
287 break;
288 case ECPGt_int:
289 case ECPGt_unsigned_int:
290 ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(int), &offset, &next_offset);
291 sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
292 sqlda->sqlvar[i].sqllen = sizeof(int);
293 break;
294 case ECPGt_long:
295 case ECPGt_unsigned_long:
296 ecpg_sqlda_align_add_size(offset, sizeof(long), sizeof(long), &offset, &next_offset);
297 sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
298 sqlda->sqlvar[i].sqllen = sizeof(long);
299 break;
300 case ECPGt_long_long:
301 case ECPGt_unsigned_long_long:
302 ecpg_sqlda_align_add_size(offset, sizeof(long long), sizeof(long long), &offset, &next_offset);
303 sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
304 sqlda->sqlvar[i].sqllen = sizeof(long long);
305 break;
306 case ECPGt_bool:
307 ecpg_sqlda_align_add_size(offset, sizeof(bool), sizeof(bool), &offset, &next_offset);
308 sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
309 sqlda->sqlvar[i].sqllen = sizeof(bool);
310 break;
311 case ECPGt_float:
312 ecpg_sqlda_align_add_size(offset, sizeof(float), sizeof(float), &offset, &next_offset);
313 sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
314 sqlda->sqlvar[i].sqllen = sizeof(float);
315 break;
316 case ECPGt_double:
317 ecpg_sqlda_align_add_size(offset, sizeof(double), sizeof(double), &offset, &next_offset);
318 sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
319 sqlda->sqlvar[i].sqllen = sizeof(double);
320 break;
321 case ECPGt_decimal:
322 ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(decimal), &offset, &next_offset);
323 sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
324 sqlda->sqlvar[i].sqllen = sizeof(decimal);
325 break;
326 case ECPGt_numeric:
327 {
328 numeric *num;
329 char *val;
330
331 set_data = false;
332
333 ecpg_sqlda_align_add_size(offset, sizeof(NumericDigit *), sizeof(numeric), &offset, &next_offset);
334 sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
335 sqlda->sqlvar[i].sqllen = sizeof(numeric);
336
337 if (PQgetisnull(res, row, i))
338 {
339 ECPGset_noind_null(ECPGt_numeric, sqlda->sqlvar[i].sqldata);
340 break;
341 }
342
343 val = PQgetvalue(res, row, i);
344 num = PGTYPESnumeric_from_asc(val, NULL);
345 if (!num)
346 {
347 ECPGset_noind_null(ECPGt_numeric, sqlda->sqlvar[i].sqldata);
348 break;
349 }
350
351 memcpy(sqlda->sqlvar[i].sqldata, num, sizeof(numeric));
352
353 if (num->buf)
354 {
355 ecpg_sqlda_align_add_size(next_offset, sizeof(int), num->digits - num->buf + num->ndigits, &offset, &next_offset);
356 memcpy((char *) sqlda + offset, num->buf, num->digits - num->buf + num->ndigits);
357
358 ((numeric *) sqlda->sqlvar[i].sqldata)->buf = (NumericDigit *) sqlda + offset;
359 ((numeric *) sqlda->sqlvar[i].sqldata)->digits = (NumericDigit *) sqlda + offset + (num->digits - num->buf);
360 }
361
362 PGTYPESnumeric_free(num);
363
364 break;
365 }
366 case ECPGt_date:
367 ecpg_sqlda_align_add_size(offset, sizeof(date), sizeof(date), &offset, &next_offset);
368 sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
369 sqlda->sqlvar[i].sqllen = sizeof(date);
370 break;
371 case ECPGt_timestamp:
372 ecpg_sqlda_align_add_size(offset, sizeof(int64), sizeof(timestamp), &offset, &next_offset);
373 sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
374 sqlda->sqlvar[i].sqllen = sizeof(timestamp);
375 break;
376 case ECPGt_interval:
377 ecpg_sqlda_align_add_size(offset, sizeof(int64), sizeof(interval), &offset, &next_offset);
378 sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
379 sqlda->sqlvar[i].sqllen = sizeof(interval);
380 break;
381 case ECPGt_char:
382 case ECPGt_unsigned_char:
383 case ECPGt_string:
384 default:
385 datalen = strlen(PQgetvalue(res, row, i)) + 1;
386 ecpg_sqlda_align_add_size(offset, sizeof(int), datalen, &offset, &next_offset);
387 sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
388 sqlda->sqlvar[i].sqllen = datalen;
389=====================================================================
390Found a 122 line (589 tokens) duplication in the following files:
391Starting at line 1295 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
392Starting at line 1539 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
393
394 int result = 0;
395 Oid tupType1;
396 Oid tupType2;
397 int32 tupTypmod1;
398 int32 tupTypmod2;
399 TupleDesc tupdesc1;
400 TupleDesc tupdesc2;
401 HeapTupleData tuple1;
402 HeapTupleData tuple2;
403 int ncolumns1;
404 int ncolumns2;
405 RecordCompareData *my_extra;
406 int ncols;
407 Datum *values1;
408 Datum *values2;
409 bool *nulls1;
410 bool *nulls2;
411 int i1;
412 int i2;
413 int j;
414
415 /* Extract type info from the tuples */
416 tupType1 = HeapTupleHeaderGetTypeId(record1);
417 tupTypmod1 = HeapTupleHeaderGetTypMod(record1);
418 tupdesc1 = lookup_rowtype_tupdesc(tupType1, tupTypmod1);
419 ncolumns1 = tupdesc1->natts;
420 tupType2 = HeapTupleHeaderGetTypeId(record2);
421 tupTypmod2 = HeapTupleHeaderGetTypMod(record2);
422 tupdesc2 = lookup_rowtype_tupdesc(tupType2, tupTypmod2);
423 ncolumns2 = tupdesc2->natts;
424
425 /* Build temporary HeapTuple control structures */
426 tuple1.t_len = HeapTupleHeaderGetDatumLength(record1);
427 ItemPointerSetInvalid(&(tuple1.t_self));
428 tuple1.t_tableOid = InvalidOid;
429 tuple1.t_data = record1;
430 tuple2.t_len = HeapTupleHeaderGetDatumLength(record2);
431 ItemPointerSetInvalid(&(tuple2.t_self));
432 tuple2.t_tableOid = InvalidOid;
433 tuple2.t_data = record2;
434
435 /*
436 * We arrange to look up the needed comparison info just once per series
437 * of calls, assuming the record types don't change underneath us.
438 */
439 ncols = Max(ncolumns1, ncolumns2);
440 my_extra = (RecordCompareData *) fcinfo->flinfo->fn_extra;
441 if (my_extra == NULL ||
442 my_extra->ncolumns < ncols)
443 {
444 fcinfo->flinfo->fn_extra =
445 MemoryContextAlloc(fcinfo->flinfo->fn_mcxt,
446 offsetof(RecordCompareData, columns) +
447 ncols * sizeof(ColumnCompareData));
448 my_extra = (RecordCompareData *) fcinfo->flinfo->fn_extra;
449 my_extra->ncolumns = ncols;
450 my_extra->record1_type = InvalidOid;
451 my_extra->record1_typmod = 0;
452 my_extra->record2_type = InvalidOid;
453 my_extra->record2_typmod = 0;
454 }
455
456 if (my_extra->record1_type != tupType1 ||
457 my_extra->record1_typmod != tupTypmod1 ||
458 my_extra->record2_type != tupType2 ||
459 my_extra->record2_typmod != tupTypmod2)
460 {
461 MemSet(my_extra->columns, 0, ncols * sizeof(ColumnCompareData));
462 my_extra->record1_type = tupType1;
463 my_extra->record1_typmod = tupTypmod1;
464 my_extra->record2_type = tupType2;
465 my_extra->record2_typmod = tupTypmod2;
466 }
467
468 /* Break down the tuples into fields */
469 values1 = (Datum *) palloc(ncolumns1 * sizeof(Datum));
470 nulls1 = (bool *) palloc(ncolumns1 * sizeof(bool));
471 heap_deform_tuple(&tuple1, tupdesc1, values1, nulls1);
472 values2 = (Datum *) palloc(ncolumns2 * sizeof(Datum));
473 nulls2 = (bool *) palloc(ncolumns2 * sizeof(bool));
474 heap_deform_tuple(&tuple2, tupdesc2, values2, nulls2);
475
476 /*
477 * Scan corresponding columns, allowing for dropped columns in different
478 * places in the two rows. i1 and i2 are physical column indexes, j is
479 * the logical column index.
480 */
481 i1 = i2 = j = 0;
482 while (i1 < ncolumns1 || i2 < ncolumns2)
483 {
484 Form_pg_attribute att1;
485 Form_pg_attribute att2;
486
487 /*
488 * Skip dropped columns
489 */
490 if (i1 < ncolumns1 && TupleDescAttr(tupdesc1, i1)->attisdropped)
491 {
492 i1++;
493 continue;
494 }
495 if (i2 < ncolumns2 && TupleDescAttr(tupdesc2, i2)->attisdropped)
496 {
497 i2++;
498 continue;
499 }
500 if (i1 >= ncolumns1 || i2 >= ncolumns2)
501 break; /* we'll deal with mismatch below loop */
502
503 att1 = TupleDescAttr(tupdesc1, i1);
504 att2 = TupleDescAttr(tupdesc2, i2);
505
506 /*
507 * Have two matching columns, they must be same type
508 */
509 if (att1->atttypid != att2->atttypid)
510 ereport(ERROR,
511 (errcode(ERRCODE_DATATYPE_MISMATCH),
512 errmsg("cannot compare dissimilar column types %s and %s at record column %d",
513 format_type_be(att1->atttypid),
514 format_type_be(att2->atttypid),
515 j + 1)));
516=====================================================================
517Found a 165 line (535 tokens) duplication in the following files:
518Starting at line 19 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/thread-thread_implicit.c
519Starting at line 18 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/thread-thread.c
520
521int
522main(void)
523{
524 printf("No threading enabled.\n");
525 return 0;
526}
527#else
528#ifndef WIN32
529#include <pthread.h>
530#else
531#include <windows.h>
532#include <locale.h>
533#endif
534
535
536#line 1 "regression.h"
537
538
539
540
541
542
543#line 24 "thread_implicit.pgc"
544
545
546void *test_thread(void *arg);
547
548int nthreads = 10;
549int iterations = 20;
550
551int main()
552{
553#ifndef WIN32
554 pthread_t *threads;
555#else
556 HANDLE *threads;
557#endif
558 int n;
559 /* exec sql begin declare section */
560
561
562#line 40 "thread_implicit.pgc"
563 int l_rows ;
564/* exec sql end declare section */
565#line 41 "thread_implicit.pgc"
566
567
568 /* Do not switch on debug output for regression tests. The threads get executed in
569 * more or less random order */
570 /* ECPGdebug(1, stderr); */
571
572 /* setup test_thread table */
573 { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0); }
574#line 48 "thread_implicit.pgc"
575
576 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table test_thread", ECPGt_EOIT, ECPGt_EORT);}
577#line 49 "thread_implicit.pgc"
578 /* DROP might fail */
579 { ECPGtrans(__LINE__, NULL, "commit");}
580#line 50 "thread_implicit.pgc"
581
582 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table test_thread ( tstamp timestamp not null default cast ( timeofday ( ) as timestamp ) , thread text not null , iteration integer not null , primary key ( thread , iteration ) )", ECPGt_EOIT, ECPGt_EORT);}
583#line 55 "thread_implicit.pgc"
584
585 { ECPGtrans(__LINE__, NULL, "commit");}
586#line 56 "thread_implicit.pgc"
587
588 { ECPGdisconnect(__LINE__, "CURRENT");}
589#line 57 "thread_implicit.pgc"
590
591
592 /* create, and start, threads */
593 threads = calloc(nthreads, sizeof(threads[0]));
594 if( threads == NULL )
595 {
596 fprintf(stderr, "Cannot alloc memory\n");
597 return 1;
598 }
599 for( n = 0; n < nthreads; n++ )
600 {
601#ifndef WIN32
602 pthread_create(&threads[n], NULL, test_thread, (void *) (long) (n + 1));
603#else
604 threads[n] = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) test_thread, (void *) (n+1), 0, NULL);
605#endif
606 }
607
608 /* wait for thread completion */
609#ifndef WIN32
610 for( n = 0; n < nthreads; n++ )
611 {
612 pthread_join(threads[n], NULL);
613 }
614#else
615 WaitForMultipleObjects(nthreads, threads, TRUE, INFINITE);
616#endif
617 free(threads);
618
619 /* and check results */
620 { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0); }
621#line 87 "thread_implicit.pgc"
622
623 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from test_thread", ECPGt_EOIT,
624 ECPGt_int,&(l_rows),(long)1,(long)1,sizeof(int),
625 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
626#line 88 "thread_implicit.pgc"
627
628 { ECPGtrans(__LINE__, NULL, "commit");}
629#line 89 "thread_implicit.pgc"
630
631 { ECPGdisconnect(__LINE__, "CURRENT");}
632#line 90 "thread_implicit.pgc"
633
634 if( l_rows == (nthreads * iterations) )
635 printf("Success.\n");
636 else
637 printf("ERROR: Failure - expecting %d rows, got %d.\n", nthreads * iterations, l_rows);
638
639 return 0;
640}
641
642void *test_thread(void *arg)
643{
644 long threadnum = (long)arg;
645
646 /* exec sql begin declare section */
647
648
649
650#line 104 "thread_implicit.pgc"
651 int l_i ;
652
653#line 105 "thread_implicit.pgc"
654 char l_connection [ 128 ] ;
655/* exec sql end declare section */
656#line 106 "thread_implicit.pgc"
657
658
659#ifdef WIN32
660#ifdef _MSC_VER /* requires MSVC */
661 _configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
662#endif
663#endif
664
665 /* build up connection name, and connect to database */
666#ifndef _MSC_VER
667 snprintf(l_connection, sizeof(l_connection), "thread_%03ld", threadnum);
668#else
669 _snprintf(l_connection, sizeof(l_connection), "thread_%03ld", threadnum);
670#endif
671 /* exec sql whenever sqlerror sqlprint ; */
672#line 120 "thread_implicit.pgc"
673
674 { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , l_connection, 0);
675#line 121 "thread_implicit.pgc"
676
677if (sqlca.sqlcode < 0) sqlprint();}
678#line 121 "thread_implicit.pgc"
679
680 if( sqlca.sqlcode != 0 )
681 {
682 printf("%s: ERROR: cannot connect to database!\n", l_connection);
683 return NULL;
684 }
685 { ECPGtrans(__LINE__, NULL, "begin");
686=====================================================================
687Found a 24 line (524 tokens) duplication in the following files:
688Starting at line 21 of /home/shackle/pggit/postgresql/contrib/ltree/_ltree_gist.c
689Starting at line 40 of /home/shackle/pggit/postgresql/contrib/pg_trgm/trgm_gist.c
690Starting at line 21 of /home/shackle/pggit/postgresql/contrib/intarray/_intbig_gist.c
691
692PG_FUNCTION_INFO_V1(_ltree_consistent);
693
694#define GETENTRY(vec,pos) ((ltree_gist *) DatumGetPointer((vec)->vector[(pos)].key))
695#define NEXTVAL(x) ( (ltree*)( (char*)(x) + INTALIGN( VARSIZE(x) ) ) )
696
697/* Number of one-bits in an unsigned byte */
698static const uint8 number_of_ones[256] = {
699 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
700 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
701 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
702 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
703 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
704 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
705 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
706 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
707 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
708 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
709 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
710 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
711 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
712 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
713 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
714 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8
715};
716=====================================================================
717Found a 29 line (524 tokens) duplication in the following files:
718Starting at line 21 of /home/shackle/pggit/postgresql/contrib/ltree/_ltree_gist.c
719Starting at line 56 of /home/shackle/pggit/postgresql/src/backend/utils/adt/tsgistidx.c
720
721PG_FUNCTION_INFO_V1(_ltree_consistent);
722
723#define GETENTRY(vec,pos) ((ltree_gist *) DatumGetPointer((vec)->vector[(pos)].key))
724#define NEXTVAL(x) ( (ltree*)( (char*)(x) + INTALIGN( VARSIZE(x) ) ) )
725
726/* Number of one-bits in an unsigned byte */
727static const uint8 number_of_ones[256] = {
728 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
729 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
730 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
731 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
732 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
733 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
734 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
735 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
736 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
737 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
738 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
739 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
740 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
741 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
742 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
743 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8
744};
745
746#define WISH_F(a,b,c) (double)( -(double)(((a)-(b))*((a)-(b))*((a)-(b)))*(c) )
747
748
749static void
750=====================================================================
751Found a 24 line (523 tokens) duplication in the following files:
752Starting at line 21 of /home/shackle/pggit/postgresql/contrib/ltree/_ltree_gist.c
753Starting at line 40 of /home/shackle/pggit/postgresql/contrib/pg_trgm/trgm_gist.c
754Starting at line 21 of /home/shackle/pggit/postgresql/contrib/intarray/_intbig_gist.c
755Starting at line 107 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
756Starting at line 56 of /home/shackle/pggit/postgresql/src/backend/utils/adt/tsgistidx.c
757
758PG_FUNCTION_INFO_V1(_ltree_consistent);
759
760#define GETENTRY(vec,pos) ((ltree_gist *) DatumGetPointer((vec)->vector[(pos)].key))
761#define NEXTVAL(x) ( (ltree*)( (char*)(x) + INTALIGN( VARSIZE(x) ) ) )
762
763/* Number of one-bits in an unsigned byte */
764static const uint8 number_of_ones[256] = {
765 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
766 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
767 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
768 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
769 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
770 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
771 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
772 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
773 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
774 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
775 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
776 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
777 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
778 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
779 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
780 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8
781};
782=====================================================================
783Found a 67 line (512 tokens) duplication in the following files:
784Starting at line 421 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/dt_common.c
785Starting at line 168 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
786
787};
788
789static const datetkn deltatktbl[] = {
790 /* text, token, lexval */
791 {"@", IGNORE_DTF, 0}, /* postgres relative prefix */
792 {DAGO, AGO, 0}, /* "ago" indicates negative time offset */
793 {"c", UNITS, DTK_CENTURY}, /* "century" relative */
794 {"cent", UNITS, DTK_CENTURY}, /* "century" relative */
795 {"centuries", UNITS, DTK_CENTURY}, /* "centuries" relative */
796 {DCENTURY, UNITS, DTK_CENTURY}, /* "century" relative */
797 {"d", UNITS, DTK_DAY}, /* "day" relative */
798 {DDAY, UNITS, DTK_DAY}, /* "day" relative */
799 {"days", UNITS, DTK_DAY}, /* "days" relative */
800 {"dec", UNITS, DTK_DECADE}, /* "decade" relative */
801 {DDECADE, UNITS, DTK_DECADE}, /* "decade" relative */
802 {"decades", UNITS, DTK_DECADE}, /* "decades" relative */
803 {"decs", UNITS, DTK_DECADE}, /* "decades" relative */
804 {"h", UNITS, DTK_HOUR}, /* "hour" relative */
805 {DHOUR, UNITS, DTK_HOUR}, /* "hour" relative */
806 {"hours", UNITS, DTK_HOUR}, /* "hours" relative */
807 {"hr", UNITS, DTK_HOUR}, /* "hour" relative */
808 {"hrs", UNITS, DTK_HOUR}, /* "hours" relative */
809 {INVALID, RESERV, DTK_INVALID}, /* reserved for invalid time */
810 {"m", UNITS, DTK_MINUTE}, /* "minute" relative */
811 {"microsecon", UNITS, DTK_MICROSEC}, /* "microsecond" relative */
812 {"mil", UNITS, DTK_MILLENNIUM}, /* "millennium" relative */
813 {"millennia", UNITS, DTK_MILLENNIUM}, /* "millennia" relative */
814 {DMILLENNIUM, UNITS, DTK_MILLENNIUM}, /* "millennium" relative */
815 {"millisecon", UNITS, DTK_MILLISEC}, /* relative */
816 {"mils", UNITS, DTK_MILLENNIUM}, /* "millennia" relative */
817 {"min", UNITS, DTK_MINUTE}, /* "minute" relative */
818 {"mins", UNITS, DTK_MINUTE}, /* "minutes" relative */
819 {DMINUTE, UNITS, DTK_MINUTE}, /* "minute" relative */
820 {"minutes", UNITS, DTK_MINUTE}, /* "minutes" relative */
821 {"mon", UNITS, DTK_MONTH}, /* "months" relative */
822 {"mons", UNITS, DTK_MONTH}, /* "months" relative */
823 {DMONTH, UNITS, DTK_MONTH}, /* "month" relative */
824 {"months", UNITS, DTK_MONTH},
825 {"ms", UNITS, DTK_MILLISEC},
826 {"msec", UNITS, DTK_MILLISEC},
827 {DMILLISEC, UNITS, DTK_MILLISEC},
828 {"mseconds", UNITS, DTK_MILLISEC},
829 {"msecs", UNITS, DTK_MILLISEC},
830 {"qtr", UNITS, DTK_QUARTER}, /* "quarter" relative */
831 {DQUARTER, UNITS, DTK_QUARTER}, /* "quarter" relative */
832 {"s", UNITS, DTK_SECOND},
833 {"sec", UNITS, DTK_SECOND},
834 {DSECOND, UNITS, DTK_SECOND},
835 {"seconds", UNITS, DTK_SECOND},
836 {"secs", UNITS, DTK_SECOND},
837 {DTIMEZONE, UNITS, DTK_TZ}, /* "timezone" time offset */
838 {"timezone_h", UNITS, DTK_TZ_HOUR}, /* timezone hour units */
839 {"timezone_m", UNITS, DTK_TZ_MINUTE}, /* timezone minutes units */
840 {"undefined", RESERV, DTK_INVALID}, /* pre-v6.1 invalid time */
841 {"us", UNITS, DTK_MICROSEC}, /* "microsecond" relative */
842 {"usec", UNITS, DTK_MICROSEC}, /* "microsecond" relative */
843 {DMICROSEC, UNITS, DTK_MICROSEC}, /* "microsecond" relative */
844 {"useconds", UNITS, DTK_MICROSEC}, /* "microseconds" relative */
845 {"usecs", UNITS, DTK_MICROSEC}, /* "microseconds" relative */
846 {"w", UNITS, DTK_WEEK}, /* "week" relative */
847 {DWEEK, UNITS, DTK_WEEK}, /* "week" relative */
848 {"weeks", UNITS, DTK_WEEK}, /* "weeks" relative */
849 {"y", UNITS, DTK_YEAR}, /* "year" relative */
850 {DYEAR, UNITS, DTK_YEAR}, /* "year" relative */
851 {"years", UNITS, DTK_YEAR}, /* "years" relative */
852 {"yr", UNITS, DTK_YEAR}, /* "year" relative */
853 {"yrs", UNITS, DTK_YEAR}, /* "years" relative */
854=====================================================================
855Found a 104 line (498 tokens) duplication in the following files:
856Starting at line 181 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-describe.c
857Starting at line 343 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-describe.c
858
859 { ECPGdescribe(__LINE__, 0, NULL, "st_id1",
860 ECPGt_descriptor, "desc4", 0L, 0L, 0L,
861 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
862#line 61 "describe.pgc"
863
864
865 strcpy(msg, "get descriptor");
866 { ECPGget_desc_header(__LINE__, "desc1", &(count1));
867
868#line 64 "describe.pgc"
869
870if (sqlca.sqlcode < 0) exit (1);}
871#line 64 "describe.pgc"
872
873 { ECPGget_desc_header(__LINE__, "desc2", &(count2));
874
875#line 65 "describe.pgc"
876
877if (sqlca.sqlcode < 0) exit (1);}
878#line 65 "describe.pgc"
879
880 { ECPGget_desc_header(__LINE__, "desc3", &(count3));
881
882#line 66 "describe.pgc"
883
884if (sqlca.sqlcode < 0) exit (1);}
885#line 66 "describe.pgc"
886
887 { ECPGget_desc_header(__LINE__, "desc4", &(count4));
888
889#line 67 "describe.pgc"
890
891if (sqlca.sqlcode < 0) exit (1);}
892#line 67 "describe.pgc"
893
894
895 if (!(count1 == count2 && count1 == count3 && count1 == count4))
896 exit(1);
897
898 for (i = 1; i <= count1; i++)
899 {
900 { ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
901 ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
902
903#line 74 "describe.pgc"
904
905if (sqlca.sqlcode < 0) exit (1);}
906#line 74 "describe.pgc"
907
908 { ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
909 ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
910
911#line 75 "describe.pgc"
912
913if (sqlca.sqlcode < 0) exit (1);}
914#line 75 "describe.pgc"
915
916 { ECPGget_desc(__LINE__, "desc3", i,ECPGd_name,
917 ECPGt_char,(field_name3),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
918
919#line 76 "describe.pgc"
920
921if (sqlca.sqlcode < 0) exit (1);}
922#line 76 "describe.pgc"
923
924 { ECPGget_desc(__LINE__, "desc4", i,ECPGd_name,
925 ECPGt_char,(field_name4),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
926
927#line 77 "describe.pgc"
928
929if (sqlca.sqlcode < 0) exit (1);}
930#line 77 "describe.pgc"
931
932 printf("field_name 1 '%s' 2 '%s' 3 '%s' 4 '%s'\n",
933 field_name1, field_name2, field_name3, field_name4);
934 }
935
936 strcpy(msg, "deallocate");
937 ECPGdeallocate_desc(__LINE__, "desc1");
938#line 83 "describe.pgc"
939
940if (sqlca.sqlcode < 0) exit (1);
941#line 83 "describe.pgc"
942
943 ECPGdeallocate_desc(__LINE__, "desc2");
944#line 84 "describe.pgc"
945
946if (sqlca.sqlcode < 0) exit (1);
947#line 84 "describe.pgc"
948
949 ECPGdeallocate_desc(__LINE__, "desc3");
950#line 85 "describe.pgc"
951
952if (sqlca.sqlcode < 0) exit (1);
953#line 85 "describe.pgc"
954
955 ECPGdeallocate_desc(__LINE__, "desc4");
956#line 86 "describe.pgc"
957
958if (sqlca.sqlcode < 0) exit (1);
959#line 86 "describe.pgc"
960
961
962 { ECPGdeallocate(__LINE__, 0, NULL, "st_id1");
963=====================================================================
964Found a 132 line (491 tokens) duplication in the following files:
965Starting at line 194 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/interval.c
966Starting at line 3589 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
967
968 tm->tm_mon += (fval * 12);
969 if (unit == '\0')
970 return 0;
971 if (unit == 'T')
972 {
973 datepart = false;
974 havefield = false;
975 continue;
976 }
977
978 dterr = ParseISO8601Number(str, &str, &val, &fval);
979 if (dterr)
980 return dterr;
981 tm->tm_mon += val;
982 AdjustFractDays(fval, tm, fsec, DAYS_PER_MONTH);
983 if (*str == '\0')
984 return 0;
985 if (*str == 'T')
986 {
987 datepart = false;
988 havefield = false;
989 continue;
990 }
991 if (*str != '-')
992 return DTERR_BAD_FORMAT;
993 str++;
994
995 dterr = ParseISO8601Number(str, &str, &val, &fval);
996 if (dterr)
997 return dterr;
998 tm->tm_mday += val;
999 AdjustFractSeconds(fval, tm, fsec, SECS_PER_DAY);
1000 if (*str == '\0')
1001 return 0;
1002 if (*str == 'T')
1003 {
1004 datepart = false;
1005 havefield = false;
1006 continue;
1007 }
1008 return DTERR_BAD_FORMAT;
1009 default:
1010 /* not a valid date unit suffix */
1011 return DTERR_BAD_FORMAT;
1012 }
1013 }
1014 else
1015 {
1016 switch (unit) /* after T: H M S */
1017 {
1018 case 'H':
1019 tm->tm_hour += val;
1020 AdjustFractSeconds(fval, tm, fsec, SECS_PER_HOUR);
1021 break;
1022 case 'M':
1023 tm->tm_min += val;
1024 AdjustFractSeconds(fval, tm, fsec, SECS_PER_MINUTE);
1025 break;
1026 case 'S':
1027 tm->tm_sec += val;
1028 AdjustFractSeconds(fval, tm, fsec, 1);
1029 break;
1030 case '\0': /* ISO 8601 4.4.3.3 Alternative Format */
1031 if (ISO8601IntegerWidth(fieldstart) == 6 && !havefield)
1032 {
1033 tm->tm_hour += val / 10000;
1034 tm->tm_min += (val / 100) % 100;
1035 tm->tm_sec += val % 100;
1036 AdjustFractSeconds(fval, tm, fsec, 1);
1037 return 0;
1038 }
1039 /* Else fall through to extended alternative format */
1040 /* FALLTHROUGH */
1041 case ':': /* ISO 8601 4.4.3.3 Alternative Format,
1042 * Extended */
1043 if (havefield)
1044 return DTERR_BAD_FORMAT;
1045
1046 tm->tm_hour += val;
1047 AdjustFractSeconds(fval, tm, fsec, SECS_PER_HOUR);
1048 if (unit == '\0')
1049 return 0;
1050
1051 dterr = ParseISO8601Number(str, &str, &val, &fval);
1052 if (dterr)
1053 return dterr;
1054 tm->tm_min += val;
1055 AdjustFractSeconds(fval, tm, fsec, SECS_PER_MINUTE);
1056 if (*str == '\0')
1057 return 0;
1058 if (*str != ':')
1059 return DTERR_BAD_FORMAT;
1060 str++;
1061
1062 dterr = ParseISO8601Number(str, &str, &val, &fval);
1063 if (dterr)
1064 return dterr;
1065 tm->tm_sec += val;
1066 AdjustFractSeconds(fval, tm, fsec, 1);
1067 if (*str == '\0')
1068 return 0;
1069 return DTERR_BAD_FORMAT;
1070
1071 default:
1072 /* not a valid time unit suffix */
1073 return DTERR_BAD_FORMAT;
1074 }
1075 }
1076
1077 havefield = true;
1078 }
1079
1080 return 0;
1081}
1082
1083
1084
1085/* copy&pasted from .../src/backend/utils/adt/datetime.c
1086 * with 3 exceptions
1087 *
1088 * * changesd struct pg_tm to struct tm
1089 *
1090 * * ECPG code called this without a 'range' parameter
1091 * removed 'int range' from the argument list and
1092 * places where DecodeTime is called; and added
1093 * int range = INTERVAL_FULL_RANGE;
1094 *
1095 * * ECPG seems not to have a global IntervalStyle
1096 * so added
1097 * int IntervalStyle = INTSTYLE_POSTGRES;
1098 */
1099int
1100=====================================================================
1101Found a 96 line (481 tokens) duplication in the following files:
1102Starting at line 788 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
1103Starting at line 1030 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
1104
1105 int result = 0;
1106 Oid tupType1;
1107 Oid tupType2;
1108 int32 tupTypmod1;
1109 int32 tupTypmod2;
1110 TupleDesc tupdesc1;
1111 TupleDesc tupdesc2;
1112 HeapTupleData tuple1;
1113 HeapTupleData tuple2;
1114 int ncolumns1;
1115 int ncolumns2;
1116 RecordCompareData *my_extra;
1117 int ncols;
1118 Datum *values1;
1119 Datum *values2;
1120 bool *nulls1;
1121 bool *nulls2;
1122 int i1;
1123 int i2;
1124 int j;
1125
1126 check_stack_depth(); /* recurses for record-type columns */
1127
1128 /* Extract type info from the tuples */
1129 tupType1 = HeapTupleHeaderGetTypeId(record1);
1130 tupTypmod1 = HeapTupleHeaderGetTypMod(record1);
1131 tupdesc1 = lookup_rowtype_tupdesc(tupType1, tupTypmod1);
1132 ncolumns1 = tupdesc1->natts;
1133 tupType2 = HeapTupleHeaderGetTypeId(record2);
1134 tupTypmod2 = HeapTupleHeaderGetTypMod(record2);
1135 tupdesc2 = lookup_rowtype_tupdesc(tupType2, tupTypmod2);
1136 ncolumns2 = tupdesc2->natts;
1137
1138 /* Build temporary HeapTuple control structures */
1139 tuple1.t_len = HeapTupleHeaderGetDatumLength(record1);
1140 ItemPointerSetInvalid(&(tuple1.t_self));
1141 tuple1.t_tableOid = InvalidOid;
1142 tuple1.t_data = record1;
1143 tuple2.t_len = HeapTupleHeaderGetDatumLength(record2);
1144 ItemPointerSetInvalid(&(tuple2.t_self));
1145 tuple2.t_tableOid = InvalidOid;
1146 tuple2.t_data = record2;
1147
1148 /*
1149 * We arrange to look up the needed comparison info just once per series
1150 * of calls, assuming the record types don't change underneath us.
1151 */
1152 ncols = Max(ncolumns1, ncolumns2);
1153 my_extra = (RecordCompareData *) fcinfo->flinfo->fn_extra;
1154 if (my_extra == NULL ||
1155 my_extra->ncolumns < ncols)
1156 {
1157 fcinfo->flinfo->fn_extra =
1158 MemoryContextAlloc(fcinfo->flinfo->fn_mcxt,
1159 offsetof(RecordCompareData, columns) +
1160 ncols * sizeof(ColumnCompareData));
1161 my_extra = (RecordCompareData *) fcinfo->flinfo->fn_extra;
1162 my_extra->ncolumns = ncols;
1163 my_extra->record1_type = InvalidOid;
1164 my_extra->record1_typmod = 0;
1165 my_extra->record2_type = InvalidOid;
1166 my_extra->record2_typmod = 0;
1167 }
1168
1169 if (my_extra->record1_type != tupType1 ||
1170 my_extra->record1_typmod != tupTypmod1 ||
1171 my_extra->record2_type != tupType2 ||
1172 my_extra->record2_typmod != tupTypmod2)
1173 {
1174 MemSet(my_extra->columns, 0, ncols * sizeof(ColumnCompareData));
1175 my_extra->record1_type = tupType1;
1176 my_extra->record1_typmod = tupTypmod1;
1177 my_extra->record2_type = tupType2;
1178 my_extra->record2_typmod = tupTypmod2;
1179 }
1180
1181 /* Break down the tuples into fields */
1182 values1 = (Datum *) palloc(ncolumns1 * sizeof(Datum));
1183 nulls1 = (bool *) palloc(ncolumns1 * sizeof(bool));
1184 heap_deform_tuple(&tuple1, tupdesc1, values1, nulls1);
1185 values2 = (Datum *) palloc(ncolumns2 * sizeof(Datum));
1186 nulls2 = (bool *) palloc(ncolumns2 * sizeof(bool));
1187 heap_deform_tuple(&tuple2, tupdesc2, values2, nulls2);
1188
1189 /*
1190 * Scan corresponding columns, allowing for dropped columns in different
1191 * places in the two rows. i1 and i2 are physical column indexes, j is
1192 * the logical column index.
1193 */
1194 i1 = i2 = j = 0;
1195 while (i1 < ncolumns1 || i2 < ncolumns2)
1196 {
1197 Form_pg_attribute att1;
1198 Form_pg_attribute att2;
1199 TypeCacheEntry *typentry;
1200 Oid collation;
1201=====================================================================
1202Found a 84 line (470 tokens) duplication in the following files:
1203Starting at line 881 of /home/shackle/pggit/postgresql/contrib/pg_trgm/trgm_gist.c
1204Starting at line 728 of /home/shackle/pggit/postgresql/src/backend/utils/adt/tsgistidx.c
1205
1206 costvector[j - 1].cost = abs(size_alpha - size_beta);
1207 }
1208 qsort((void *) costvector, maxoff, sizeof(SPLITCOST), comparecost);
1209
1210 for (k = 0; k < maxoff; k++)
1211 {
1212 j = costvector[k].pos;
1213 if (j == seed_1)
1214 {
1215 *left++ = j;
1216 v->spl_nleft++;
1217 continue;
1218 }
1219 else if (j == seed_2)
1220 {
1221 *right++ = j;
1222 v->spl_nright++;
1223 continue;
1224 }
1225
1226 if (ISALLTRUE(datum_l) || cache[j].allistrue)
1227 {
1228 if (ISALLTRUE(datum_l) && cache[j].allistrue)
1229 size_alpha = 0;
1230 else
1231 size_alpha = SIGLENBIT - sizebitvec(
1232 (cache[j].allistrue) ? GETSIGN(datum_l) : GETSIGN(cache[j].sign)
1233 );
1234 }
1235 else
1236 size_alpha = hemdistsign(cache[j].sign, GETSIGN(datum_l));
1237
1238 if (ISALLTRUE(datum_r) || cache[j].allistrue)
1239 {
1240 if (ISALLTRUE(datum_r) && cache[j].allistrue)
1241 size_beta = 0;
1242 else
1243 size_beta = SIGLENBIT - sizebitvec(
1244 (cache[j].allistrue) ? GETSIGN(datum_r) : GETSIGN(cache[j].sign)
1245 );
1246 }
1247 else
1248 size_beta = hemdistsign(cache[j].sign, GETSIGN(datum_r));
1249
1250 if (size_alpha < size_beta + WISH_F(v->spl_nleft, v->spl_nright, 0.1))
1251 {
1252 if (ISALLTRUE(datum_l) || cache[j].allistrue)
1253 {
1254 if (!ISALLTRUE(datum_l))
1255 MemSet((void *) GETSIGN(datum_l), 0xff, sizeof(BITVEC));
1256 }
1257 else
1258 {
1259 ptr = cache[j].sign;
1260 LOOPBYTE
1261 union_l[i] |= ptr[i];
1262 }
1263 *left++ = j;
1264 v->spl_nleft++;
1265 }
1266 else
1267 {
1268 if (ISALLTRUE(datum_r) || cache[j].allistrue)
1269 {
1270 if (!ISALLTRUE(datum_r))
1271 MemSet((void *) GETSIGN(datum_r), 0xff, sizeof(BITVEC));
1272 }
1273 else
1274 {
1275 ptr = cache[j].sign;
1276 LOOPBYTE
1277 union_r[i] |= ptr[i];
1278 }
1279 *right++ = j;
1280 v->spl_nright++;
1281 }
1282 }
1283
1284 *right = *left = FirstOffsetNumber;
1285 v->spl_ldatum = PointerGetDatum(datum_l);
1286 v->spl_rdatum = PointerGetDatum(datum_r);
1287
1288 PG_RETURN_POINTER(v);
1289}
1290=====================================================================
1291Found a 37 line (467 tokens) duplication in the following files:
1292Starting at line 194 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/compat_informix-rnull.c
1293Starting at line 234 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/compat_informix-rnull.c
1294
1295 { ECPGdo(__LINE__, 1, 0, NULL, 0, ECPGst_normal, "select c , s , i , b , f , l , dbl , dec , dat , tmp from test where id = 1", ECPGt_EOIT,
1296 ECPGt_char,(c),(long)sizeof("abc"),(long)1,(sizeof("abc"))*sizeof(char),
1297 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
1298 ECPGt_short,&(s),(long)1,(long)1,sizeof(short),
1299 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
1300 ECPGt_int,&(i),(long)1,(long)1,sizeof(int),
1301 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
1302 ECPGt_bool,&(b),(long)1,(long)1,sizeof(bool),
1303 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
1304 ECPGt_float,&(f),(long)1,(long)1,sizeof(float),
1305 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
1306 ECPGt_long,&(l),(long)1,(long)1,sizeof(long),
1307 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
1308 ECPGt_double,&(dbl),(long)1,(long)1,sizeof(double),
1309 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
1310 ECPGt_decimal,&(dec),(long)1,(long)1,sizeof(decimal),
1311 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
1312 ECPGt_date,&(dat),(long)1,(long)1,sizeof(date),
1313 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
1314 ECPGt_timestamp,&(tmp),(long)1,(long)1,sizeof(timestamp),
1315 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
1316#line 61 "rnull.pgc"
1317
1318if (sqlca.sqlcode < 0) sqlprint ( );}
1319#line 61 "rnull.pgc"
1320
1321
1322 test_null(CCHARTYPE, (char *) c);
1323 test_null(CSHORTTYPE, (char *) &s);
1324 test_null(CINTTYPE, (char *) &i);
1325 test_null(CBOOLTYPE, (char *) &b);
1326 test_null(CFLOATTYPE, (char *) &f);
1327 test_null(CLONGTYPE, (char *) &l);
1328 test_null(CDOUBLETYPE, (char *) &dbl);
1329 test_null(CDECIMALTYPE, (char *) &dec);
1330 test_null(CDATETYPE, (char *) &dat);
1331 test_null(CDTIMETYPE, (char *) &tmp);
1332=====================================================================
1333Found a 71 line (456 tokens) duplication in the following files:
1334Starting at line 360 of /home/shackle/pggit/postgresql/contrib/hstore/hstore_gist.c
1335Starting at line 354 of /home/shackle/pggit/postgresql/contrib/intarray/_intbig_gist.c
1336
1337 *_j;
1338
1339 nbytes = (maxoff + 2) * sizeof(OffsetNumber);
1340 v->spl_left = (OffsetNumber *) palloc(nbytes);
1341 v->spl_right = (OffsetNumber *) palloc(nbytes);
1342
1343 for (k = FirstOffsetNumber; k < maxoff; k = OffsetNumberNext(k))
1344 {
1345 _k = GETENTRY(entryvec, k);
1346 for (j = OffsetNumberNext(k); j <= maxoff; j = OffsetNumberNext(j))
1347 {
1348 size_waste = hemdist(_k, GETENTRY(entryvec, j));
1349 if (size_waste > waste)
1350 {
1351 waste = size_waste;
1352 seed_1 = k;
1353 seed_2 = j;
1354 }
1355 }
1356 }
1357
1358 left = v->spl_left;
1359 v->spl_nleft = 0;
1360 right = v->spl_right;
1361 v->spl_nright = 0;
1362
1363 if (seed_1 == 0 || seed_2 == 0)
1364 {
1365 seed_1 = 1;
1366 seed_2 = 2;
1367 }
1368
1369 /* form initial .. */
1370 if (ISALLTRUE(GETENTRY(entryvec, seed_1)))
1371 {
1372 datum_l = (GISTTYPE *) palloc(GTHDRSIZE);
1373 SET_VARSIZE(datum_l, GTHDRSIZE);
1374 datum_l->flag = ALLISTRUE;
1375 }
1376 else
1377 {
1378 datum_l = (GISTTYPE *) palloc(GTHDRSIZE + SIGLEN);
1379 SET_VARSIZE(datum_l, GTHDRSIZE + SIGLEN);
1380 datum_l->flag = 0;
1381 memcpy((void *) GETSIGN(datum_l), (void *) GETSIGN(GETENTRY(entryvec, seed_1)), sizeof(BITVEC))
1382 ;
1383 }
1384 if (ISALLTRUE(GETENTRY(entryvec, seed_2)))
1385 {
1386 datum_r = (GISTTYPE *) palloc(GTHDRSIZE);
1387 SET_VARSIZE(datum_r, GTHDRSIZE);
1388 datum_r->flag = ALLISTRUE;
1389 }
1390 else
1391 {
1392 datum_r = (GISTTYPE *) palloc(GTHDRSIZE + SIGLEN);
1393 SET_VARSIZE(datum_r, GTHDRSIZE + SIGLEN);
1394 datum_r->flag = 0;
1395 memcpy((void *) GETSIGN(datum_r), (void *) GETSIGN(GETENTRY(entryvec, seed_2)), sizeof(BITVEC));
1396 }
1397
1398 maxoff = OffsetNumberNext(maxoff);
1399 /* sort before ... */
1400 costvector = (SPLITCOST *) palloc(sizeof(SPLITCOST) * maxoff);
1401 for (j = FirstOffsetNumber; j <= maxoff; j = OffsetNumberNext(j))
1402 {
1403 costvector[j - 1].pos = j;
1404 _j = GETENTRY(entryvec, j);
1405 size_alpha = hemdist(datum_l, _j);
1406 size_beta = hemdist(datum_r, _j);
1407 costvector[j - 1].cost = abs(size_alpha - size_beta);
1408=====================================================================
1409Found a 101 line (456 tokens) duplication in the following files:
1410Starting at line 3570 of /home/shackle/pggit/postgresql/src/backend/utils/adt/timestamp.c
1411Starting at line 3691 of /home/shackle/pggit/postgresql/src/backend/utils/adt/timestamp.c
1412
1413 timestamp2tm(dt2, NULL, tm2, &fsec2, NULL, NULL) == 0)
1414 {
1415 /* form the symbolic difference */
1416 fsec = fsec1 - fsec2;
1417 tm->tm_sec = tm1->tm_sec - tm2->tm_sec;
1418 tm->tm_min = tm1->tm_min - tm2->tm_min;
1419 tm->tm_hour = tm1->tm_hour - tm2->tm_hour;
1420 tm->tm_mday = tm1->tm_mday - tm2->tm_mday;
1421 tm->tm_mon = tm1->tm_mon - tm2->tm_mon;
1422 tm->tm_year = tm1->tm_year - tm2->tm_year;
1423
1424 /* flip sign if necessary... */
1425 if (dt1 < dt2)
1426 {
1427 fsec = -fsec;
1428 tm->tm_sec = -tm->tm_sec;
1429 tm->tm_min = -tm->tm_min;
1430 tm->tm_hour = -tm->tm_hour;
1431 tm->tm_mday = -tm->tm_mday;
1432 tm->tm_mon = -tm->tm_mon;
1433 tm->tm_year = -tm->tm_year;
1434 }
1435
1436 /* propagate any negative fields into the next higher field */
1437 while (fsec < 0)
1438 {
1439 fsec += USECS_PER_SEC;
1440 tm->tm_sec--;
1441 }
1442
1443 while (tm->tm_sec < 0)
1444 {
1445 tm->tm_sec += SECS_PER_MINUTE;
1446 tm->tm_min--;
1447 }
1448
1449 while (tm->tm_min < 0)
1450 {
1451 tm->tm_min += MINS_PER_HOUR;
1452 tm->tm_hour--;
1453 }
1454
1455 while (tm->tm_hour < 0)
1456 {
1457 tm->tm_hour += HOURS_PER_DAY;
1458 tm->tm_mday--;
1459 }
1460
1461 while (tm->tm_mday < 0)
1462 {
1463 if (dt1 < dt2)
1464 {
1465 tm->tm_mday += day_tab[isleap(tm1->tm_year)][tm1->tm_mon - 1];
1466 tm->tm_mon--;
1467 }
1468 else
1469 {
1470 tm->tm_mday += day_tab[isleap(tm2->tm_year)][tm2->tm_mon - 1];
1471 tm->tm_mon--;
1472 }
1473 }
1474
1475 while (tm->tm_mon < 0)
1476 {
1477 tm->tm_mon += MONTHS_PER_YEAR;
1478 tm->tm_year--;
1479 }
1480
1481 /* recover sign if necessary... */
1482 if (dt1 < dt2)
1483 {
1484 fsec = -fsec;
1485 tm->tm_sec = -tm->tm_sec;
1486 tm->tm_min = -tm->tm_min;
1487 tm->tm_hour = -tm->tm_hour;
1488 tm->tm_mday = -tm->tm_mday;
1489 tm->tm_mon = -tm->tm_mon;
1490 tm->tm_year = -tm->tm_year;
1491 }
1492
1493 if (tm2interval(tm, fsec, result) != 0)
1494 ereport(ERROR,
1495 (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
1496 errmsg("interval out of range")));
1497 }
1498 else
1499 ereport(ERROR,
1500 (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
1501 errmsg("timestamp out of range")));
1502
1503 PG_RETURN_INTERVAL_P(result);
1504}
1505
1506
1507/* timestamptz_age()
1508 * Calculate time difference while retaining year/month fields.
1509 * Note that this does not result in an accurate absolute time span
1510 * since year and month are out of context once the arithmetic
1511 * is done.
1512 */
1513Datum
1514=====================================================================
1515Found a 116 line (443 tokens) duplication in the following files:
1516Starting at line 984 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
1517Starting at line 1891 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
1518
1519 errno = 0;
1520 val = strtoint(field[i], &cp, 10);
1521 if (errno == ERANGE)
1522 return DTERR_FIELD_OVERFLOW;
1523
1524 /*
1525 * only a few kinds are allowed to have an embedded
1526 * decimal
1527 */
1528 if (*cp == '.')
1529 switch (ptype)
1530 {
1531 case DTK_JULIAN:
1532 case DTK_TIME:
1533 case DTK_SECOND:
1534 break;
1535 default:
1536 return DTERR_BAD_FORMAT;
1537 break;
1538 }
1539 else if (*cp != '\0')
1540 return DTERR_BAD_FORMAT;
1541
1542 switch (ptype)
1543 {
1544 case DTK_YEAR:
1545 tm->tm_year = val;
1546 tmask = DTK_M(YEAR);
1547 break;
1548
1549 case DTK_MONTH:
1550
1551 /*
1552 * already have a month and hour? then assume
1553 * minutes
1554 */
1555 if ((fmask & DTK_M(MONTH)) != 0 &&
1556 (fmask & DTK_M(HOUR)) != 0)
1557 {
1558 tm->tm_min = val;
1559 tmask = DTK_M(MINUTE);
1560 }
1561 else
1562 {
1563 tm->tm_mon = val;
1564 tmask = DTK_M(MONTH);
1565 }
1566 break;
1567
1568 case DTK_DAY:
1569 tm->tm_mday = val;
1570 tmask = DTK_M(DAY);
1571 break;
1572
1573 case DTK_HOUR:
1574 tm->tm_hour = val;
1575 tmask = DTK_M(HOUR);
1576 break;
1577
1578 case DTK_MINUTE:
1579 tm->tm_min = val;
1580 tmask = DTK_M(MINUTE);
1581 break;
1582
1583 case DTK_SECOND:
1584 tm->tm_sec = val;
1585 tmask = DTK_M(SECOND);
1586 if (*cp == '.')
1587 {
1588 dterr = ParseFractionalSecond(cp, fsec);
1589 if (dterr)
1590 return dterr;
1591 tmask = DTK_ALL_SECS_M;
1592 }
1593 break;
1594
1595 case DTK_TZ:
1596 tmask = DTK_M(TZ);
1597 dterr = DecodeTimezone(field[i], tzp);
1598 if (dterr)
1599 return dterr;
1600 break;
1601
1602 case DTK_JULIAN:
1603 /* previous field was a label for "julian date" */
1604 if (val < 0)
1605 return DTERR_FIELD_OVERFLOW;
1606 tmask = DTK_DATE_M;
1607 j2date(val, &tm->tm_year, &tm->tm_mon, &tm->tm_mday);
1608 isjulian = true;
1609
1610 /* fractional Julian Day? */
1611 if (*cp == '.')
1612 {
1613 double time;
1614
1615 errno = 0;
1616 time = strtod(cp, &cp);
1617 if (*cp != '\0' || errno != 0)
1618 return DTERR_BAD_FORMAT;
1619 time *= USECS_PER_DAY;
1620 dt2time(time,
1621 &tm->tm_hour, &tm->tm_min,
1622 &tm->tm_sec, fsec);
1623 tmask |= DTK_TIME_M;
1624 }
1625 break;
1626
1627 case DTK_TIME:
1628 /* previous field was "t" for ISO time */
1629 dterr = DecodeNumberField(strlen(field[i]), field[i],
1630 (fmask | DTK_DATE_M),
1631 &tmask, tm,
1632 fsec, &is2digits);
1633 if (dterr < 0)
1634 return dterr;
1635=====================================================================
1636Found a 130 line (420 tokens) duplication in the following files:
1637Starting at line 554 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/interval.c
1638Starting at line 3317 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
1639
1640 tmask = (fmask & DTK_M(YEAR)) ? 0 : DTK_M(YEAR);
1641 break;
1642
1643 default:
1644 return DTERR_BAD_FORMAT;
1645 }
1646 break;
1647
1648 case DTK_STRING:
1649 case DTK_SPECIAL:
1650 type = DecodeUnits(i, field[i], &val);
1651 if (type == IGNORE_DTF)
1652 continue;
1653
1654 tmask = 0; /* DTK_M(type); */
1655 switch (type)
1656 {
1657 case UNITS:
1658 type = val;
1659 break;
1660
1661 case AGO:
1662 is_before = true;
1663 type = val;
1664 break;
1665
1666 case RESERV:
1667 tmask = (DTK_DATE_M | DTK_TIME_M);
1668 *dtype = val;
1669 break;
1670
1671 default:
1672 return DTERR_BAD_FORMAT;
1673 }
1674 break;
1675
1676 default:
1677 return DTERR_BAD_FORMAT;
1678 }
1679
1680 if (tmask & fmask)
1681 return DTERR_BAD_FORMAT;
1682 fmask |= tmask;
1683 }
1684
1685 /* ensure that at least one time field has been found */
1686 if (fmask == 0)
1687 return DTERR_BAD_FORMAT;
1688
1689 /* ensure fractional seconds are fractional */
1690 if (*fsec != 0)
1691 {
1692 int sec;
1693
1694 sec = *fsec / USECS_PER_SEC;
1695 *fsec -= sec * USECS_PER_SEC;
1696 tm->tm_sec += sec;
1697 }
1698
1699 /*----------
1700 * The SQL standard defines the interval literal
1701 * '-1 1:00:00'
1702 * to mean "negative 1 days and negative 1 hours", while Postgres
1703 * traditionally treats this as meaning "negative 1 days and positive
1704 * 1 hours". In SQL_STANDARD intervalstyle, we apply the leading sign
1705 * to all fields if there are no other explicit signs.
1706 *
1707 * We leave the signs alone if there are additional explicit signs.
1708 * This protects us against misinterpreting postgres-style dump output,
1709 * since the postgres-style output code has always put an explicit sign on
1710 * all fields following a negative field. But note that SQL-spec output
1711 * is ambiguous and can be misinterpreted on load! (So it's best practice
1712 * to dump in postgres style, not SQL style.)
1713 *----------
1714 */
1715 if (IntervalStyle == INTSTYLE_SQL_STANDARD && *field[0] == '-')
1716 {
1717 /* Check for additional explicit signs */
1718 bool more_signs = false;
1719
1720 for (i = 1; i < nf; i++)
1721 {
1722 if (*field[i] == '-' || *field[i] == '+')
1723 {
1724 more_signs = true;
1725 break;
1726 }
1727 }
1728
1729 if (!more_signs)
1730 {
1731 /*
1732 * Rather than re-determining which field was field[0], just force
1733 * 'em all negative.
1734 */
1735 if (*fsec > 0)
1736 *fsec = -(*fsec);
1737 if (tm->tm_sec > 0)
1738 tm->tm_sec = -tm->tm_sec;
1739 if (tm->tm_min > 0)
1740 tm->tm_min = -tm->tm_min;
1741 if (tm->tm_hour > 0)
1742 tm->tm_hour = -tm->tm_hour;
1743 if (tm->tm_mday > 0)
1744 tm->tm_mday = -tm->tm_mday;
1745 if (tm->tm_mon > 0)
1746 tm->tm_mon = -tm->tm_mon;
1747 if (tm->tm_year > 0)
1748 tm->tm_year = -tm->tm_year;
1749 }
1750 }
1751
1752 /* finally, AGO negates everything */
1753 if (is_before)
1754 {
1755 *fsec = -(*fsec);
1756 tm->tm_sec = -tm->tm_sec;
1757 tm->tm_min = -tm->tm_min;
1758 tm->tm_hour = -tm->tm_hour;
1759 tm->tm_mday = -tm->tm_mday;
1760 tm->tm_mon = -tm->tm_mon;
1761 tm->tm_year = -tm->tm_year;
1762 }
1763
1764 return 0;
1765}
1766
1767
1768/* copy&pasted from .../src/backend/utils/adt/datetime.c */
1769static char *
1770=====================================================================
1771Found a 73 line (408 tokens) duplication in the following files:
1772Starting at line 809 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
1773Starting at line 1051 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
1774Starting at line 1314 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
1775Starting at line 1558 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
1776
1777 check_stack_depth(); /* recurses for record-type columns */
1778
1779 /* Extract type info from the tuples */
1780 tupType1 = HeapTupleHeaderGetTypeId(record1);
1781 tupTypmod1 = HeapTupleHeaderGetTypMod(record1);
1782 tupdesc1 = lookup_rowtype_tupdesc(tupType1, tupTypmod1);
1783 ncolumns1 = tupdesc1->natts;
1784 tupType2 = HeapTupleHeaderGetTypeId(record2);
1785 tupTypmod2 = HeapTupleHeaderGetTypMod(record2);
1786 tupdesc2 = lookup_rowtype_tupdesc(tupType2, tupTypmod2);
1787 ncolumns2 = tupdesc2->natts;
1788
1789 /* Build temporary HeapTuple control structures */
1790 tuple1.t_len = HeapTupleHeaderGetDatumLength(record1);
1791 ItemPointerSetInvalid(&(tuple1.t_self));
1792 tuple1.t_tableOid = InvalidOid;
1793 tuple1.t_data = record1;
1794 tuple2.t_len = HeapTupleHeaderGetDatumLength(record2);
1795 ItemPointerSetInvalid(&(tuple2.t_self));
1796 tuple2.t_tableOid = InvalidOid;
1797 tuple2.t_data = record2;
1798
1799 /*
1800 * We arrange to look up the needed comparison info just once per series
1801 * of calls, assuming the record types don't change underneath us.
1802 */
1803 ncols = Max(ncolumns1, ncolumns2);
1804 my_extra = (RecordCompareData *) fcinfo->flinfo->fn_extra;
1805 if (my_extra == NULL ||
1806 my_extra->ncolumns < ncols)
1807 {
1808 fcinfo->flinfo->fn_extra =
1809 MemoryContextAlloc(fcinfo->flinfo->fn_mcxt,
1810 offsetof(RecordCompareData, columns) +
1811 ncols * sizeof(ColumnCompareData));
1812 my_extra = (RecordCompareData *) fcinfo->flinfo->fn_extra;
1813 my_extra->ncolumns = ncols;
1814 my_extra->record1_type = InvalidOid;
1815 my_extra->record1_typmod = 0;
1816 my_extra->record2_type = InvalidOid;
1817 my_extra->record2_typmod = 0;
1818 }
1819
1820 if (my_extra->record1_type != tupType1 ||
1821 my_extra->record1_typmod != tupTypmod1 ||
1822 my_extra->record2_type != tupType2 ||
1823 my_extra->record2_typmod != tupTypmod2)
1824 {
1825 MemSet(my_extra->columns, 0, ncols * sizeof(ColumnCompareData));
1826 my_extra->record1_type = tupType1;
1827 my_extra->record1_typmod = tupTypmod1;
1828 my_extra->record2_type = tupType2;
1829 my_extra->record2_typmod = tupTypmod2;
1830 }
1831
1832 /* Break down the tuples into fields */
1833 values1 = (Datum *) palloc(ncolumns1 * sizeof(Datum));
1834 nulls1 = (bool *) palloc(ncolumns1 * sizeof(bool));
1835 heap_deform_tuple(&tuple1, tupdesc1, values1, nulls1);
1836 values2 = (Datum *) palloc(ncolumns2 * sizeof(Datum));
1837 nulls2 = (bool *) palloc(ncolumns2 * sizeof(bool));
1838 heap_deform_tuple(&tuple2, tupdesc2, values2, nulls2);
1839
1840 /*
1841 * Scan corresponding columns, allowing for dropped columns in different
1842 * places in the two rows. i1 and i2 are physical column indexes, j is
1843 * the logical column index.
1844 */
1845 i1 = i2 = j = 0;
1846 while (i1 < ncolumns1 || i2 < ncolumns2)
1847 {
1848 Form_pg_attribute att1;
1849 Form_pg_attribute att2;
1850=====================================================================
1851Found a 18 line (397 tokens) duplication in the following files:
1852Starting at line 206 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-outofscope.c
1853Starting at line 230 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-outofscope.c
1854
1855 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare mycur cursor for select * from a1", ECPGt_EOIT,
1856 ECPGt_int,&((*( MYTYPE *)(ECPGget_var( 0)) ).id),(long)1,(long)1,sizeof( struct mytype ),
1857 ECPGt_int,&((*( MYNULLTYPE *)(ECPGget_var( 1)) ).id),(long)1,(long)1,sizeof( struct mynulltype ),
1858 ECPGt_char,&((*( MYTYPE *)(ECPGget_var( 0)) ).t),(long)64,(long)1,sizeof( struct mytype ),
1859 ECPGt_int,&((*( MYNULLTYPE *)(ECPGget_var( 1)) ).t),(long)1,(long)1,sizeof( struct mynulltype ),
1860 ECPGt_double,&((*( MYTYPE *)(ECPGget_var( 0)) ).d1),(long)1,(long)1,sizeof( struct mytype ),
1861 ECPGt_int,&((*( MYNULLTYPE *)(ECPGget_var( 1)) ).d1),(long)1,(long)1,sizeof( struct mynulltype ),
1862 ECPGt_double,&((*( MYTYPE *)(ECPGget_var( 0)) ).d2),(long)1,(long)1,sizeof( struct mytype ),
1863 ECPGt_int,&((*( MYNULLTYPE *)(ECPGget_var( 1)) ).d2),(long)1,(long)1,sizeof( struct mynulltype ),
1864 ECPGt_char,&((*( MYTYPE *)(ECPGget_var( 0)) ).c),(long)30,(long)1,sizeof( struct mytype ),
1865 ECPGt_int,&((*( MYNULLTYPE *)(ECPGget_var( 1)) ).c),(long)1,(long)1,sizeof( struct mynulltype ), ECPGt_EORT);
1866#line 40 "outofscope.pgc"
1867
1868if (sqlca.sqlcode < 0) exit (1);}
1869#line 40 "outofscope.pgc"
1870
1871
1872 if (sqlca.sqlcode != 0)
1873=====================================================================
1874Found a 86 line (388 tokens) duplication in the following files:
1875Starting at line 197 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/compat_informix-describe.c
1876Starting at line 195 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-describe.c
1877
1878 { ECPGdescribe(__LINE__, 1, 0, NULL, "st_id1",
1879 ECPGt_sqlda, &sqlda3, 0L, 0L, 0L,
1880 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
1881#line 65 "describe.pgc"
1882
1883
1884 if (sqlda1 == NULL)
1885 {
1886 printf("sqlda1 NULL\n");
1887 exit(1);
1888 }
1889
1890 if (sqlda2 == NULL)
1891 {
1892 printf("sqlda2 NULL\n");
1893 exit(1);
1894 }
1895
1896 if (sqlda3 == NULL)
1897 {
1898 printf("sqlda3 NULL\n");
1899 exit(1);
1900 }
1901
1902 strcpy(msg, "get descriptor");
1903 { ECPGget_desc_header(__LINE__, "desc1", &(count1));
1904
1905#line 86 "describe.pgc"
1906
1907if (sqlca.sqlcode < 0) exit (1);}
1908#line 86 "describe.pgc"
1909
1910 { ECPGget_desc_header(__LINE__, "desc1", &(count2));
1911
1912#line 87 "describe.pgc"
1913
1914if (sqlca.sqlcode < 0) exit (1);}
1915#line 87 "describe.pgc"
1916
1917
1918 if (count1 != count2)
1919 {
1920 printf("count1 (%d) != count2 (%d)\n", count1, count2);
1921 exit(1);
1922 }
1923
1924 if (count1 != sqlda1->sqld)
1925 {
1926 printf("count1 (%d) != sqlda1->sqld (%d)\n", count1, sqlda1->sqld);
1927 exit(1);
1928 }
1929
1930 if (count1 != sqlda2->sqld)
1931 {
1932 printf("count1 (%d) != sqlda2->sqld (%d)\n", count1, sqlda2->sqld);
1933 exit(1);
1934 }
1935
1936 if (count1 != sqlda3->sqld)
1937 {
1938 printf("count1 (%d) != sqlda3->sqld (%d)\n", count1, sqlda3->sqld);
1939 exit(1);
1940 }
1941
1942 for (i = 1; i <= count1; i++)
1943 {
1944 { ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
1945 ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
1946
1947#line 115 "describe.pgc"
1948
1949if (sqlca.sqlcode < 0) exit (1);}
1950#line 115 "describe.pgc"
1951
1952 { ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
1953 ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
1954
1955#line 116 "describe.pgc"
1956
1957if (sqlca.sqlcode < 0) exit (1);}
1958#line 116 "describe.pgc"
1959
1960 printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
1961 "sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n",
1962 i, field_name1, field_name2,
1963 sqlda1->sqlvar[i-1].sqlname,
1964=====================================================================
1965Found a 16 line (385 tokens) duplication in the following files:
1966Starting at line 3556 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
1967Starting at line 104 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
1968
1969 return PQescapeInternal(conn, str, len, true);
1970}
1971
1972/* HEX encoding support for bytea */
1973static const char hextbl[] = "0123456789abcdef";
1974
1975static const int8 hexlookup[128] = {
1976 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1977 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1978 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1979 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1,
1980 -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1981 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1982 -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1983 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1984};
1985=====================================================================
1986Found a 73 line (374 tokens) duplication in the following files:
1987Starting at line 763 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/interval.c
1988Starting at line 4229 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
1989
1990EncodeInterval(struct /* pg_ */ tm *tm, fsec_t fsec, int style, char *str)
1991{
1992 char *cp = str;
1993 int year = tm->tm_year;
1994 int mon = tm->tm_mon;
1995 int mday = tm->tm_mday;
1996 int hour = tm->tm_hour;
1997 int min = tm->tm_min;
1998 int sec = tm->tm_sec;
1999 bool is_before = false;
2000 bool is_zero = true;
2001
2002 /*
2003 * The sign of year and month are guaranteed to match, since they are
2004 * stored internally as "month". But we'll need to check for is_before and
2005 * is_zero when determining the signs of day and hour/minute/seconds
2006 * fields.
2007 */
2008 switch (style)
2009 {
2010 /* SQL Standard interval format */
2011 case INTSTYLE_SQL_STANDARD:
2012 {
2013 bool has_negative = year < 0 || mon < 0 ||
2014 mday < 0 || hour < 0 ||
2015 min < 0 || sec < 0 || fsec < 0;
2016 bool has_positive = year > 0 || mon > 0 ||
2017 mday > 0 || hour > 0 ||
2018 min > 0 || sec > 0 || fsec > 0;
2019 bool has_year_month = year != 0 || mon != 0;
2020 bool has_day_time = mday != 0 || hour != 0 ||
2021 min != 0 || sec != 0 || fsec != 0;
2022 bool has_day = mday != 0;
2023 bool sql_standard_value = !(has_negative && has_positive) &&
2024 !(has_year_month && has_day_time);
2025
2026 /*
2027 * SQL Standard wants only 1 "<sign>" preceding the whole
2028 * interval ... but can't do that if mixed signs.
2029 */
2030 if (has_negative && sql_standard_value)
2031 {
2032 *cp++ = '-';
2033 year = -year;
2034 mon = -mon;
2035 mday = -mday;
2036 hour = -hour;
2037 min = -min;
2038 sec = -sec;
2039 fsec = -fsec;
2040 }
2041
2042 if (!has_negative && !has_positive)
2043 {
2044 sprintf(cp, "0");
2045 }
2046 else if (!sql_standard_value)
2047 {
2048 /*
2049 * For non sql-standard interval values, force outputting
2050 * the signs to avoid ambiguities with intervals with
2051 * mixed sign components.
2052 */
2053 char year_sign = (year < 0 || mon < 0) ? '-' : '+';
2054 char day_sign = (mday < 0) ? '-' : '+';
2055 char sec_sign = (hour < 0 || min < 0 ||
2056 sec < 0 || fsec < 0) ? '-' : '+';
2057
2058 sprintf(cp, "%c%d-%d %c%d %c%d:%02d:",
2059 year_sign, abs(year), abs(mon),
2060 day_sign, abs(mday),
2061 sec_sign, abs(hour), abs(min));
2062 cp += strlen(cp);
2063=====================================================================
2064Found a 12 line (372 tokens) duplication in the following files:
2065Starting at line 3562 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
2066Starting at line 40 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
2067
2068static const int8 hexlookup[128] = {
2069 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2070 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2071 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2072 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1,
2073 -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2074 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2075 -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2076 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2077};
2078
2079static inline char
2080=====================================================================
2081Found a 10 line (370 tokens) duplication in the following files:
2082Starting at line 114 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
2083Starting at line 40 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
2084
2085static const int8 hexlookup[128] = {
2086 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2087 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2088 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2089 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1,
2090 -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2091 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2092 -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2093 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2094};
2095=====================================================================
2096Found a 13 line (340 tokens) duplication in the following files:
2097Starting at line 27 of /home/shackle/pggit/postgresql/src/common/base64.c
2098Starting at line 203 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
2099
2100static const char _base64[] =
2101"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
2102
2103static const int8 b64lookup[128] = {
2104 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2105 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2106 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
2107 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1,
2108 -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
2109 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
2110 -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
2111 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1,
2112};
2113=====================================================================
2114Found a 21 line (330 tokens) duplication in the following files:
2115Starting at line 159 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/compat_informix-rnull.c
2116Starting at line 194 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/compat_informix-rnull.c
2117Starting at line 234 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/compat_informix-rnull.c
2118
2119 { ECPGdo(__LINE__, 1, 0, NULL, 0, ECPGst_normal, "insert into test ( id , c , s , i , b , f , l , dbl , dec , dat , tmp ) values ( 2 , $1 , $2 , $3 , $4 , $5 , $6 , $7 , $8 , $9 , $10 )",
2120 ECPGt_char,(c),(long)sizeof("abc"),(long)1,(sizeof("abc"))*sizeof(char),
2121 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
2122 ECPGt_short,&(s),(long)1,(long)1,sizeof(short),
2123 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
2124 ECPGt_int,&(i),(long)1,(long)1,sizeof(int),
2125 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
2126 ECPGt_bool,&(b),(long)1,(long)1,sizeof(bool),
2127 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
2128 ECPGt_float,&(f),(long)1,(long)1,sizeof(float),
2129 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
2130 ECPGt_long,&(l),(long)1,(long)1,sizeof(long),
2131 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
2132 ECPGt_double,&(dbl),(long)1,(long)1,sizeof(double),
2133 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
2134 ECPGt_decimal,&(dec),(long)1,(long)1,sizeof(decimal),
2135 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
2136 ECPGt_date,&(dat),(long)1,(long)1,sizeof(date),
2137 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
2138 ECPGt_timestamp,&(tmp),(long)1,(long)1,sizeof(timestamp),
2139 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
2140=====================================================================
2141Found a 56 line (300 tokens) duplication in the following files:
2142Starting at line 10205 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_dump.c
2143Starting at line 10560 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_dump.c
2144
2145 appendPQExpBuffer(q, ",\n subtype_diff = %s", procname);
2146
2147 appendPQExpBufferStr(q, "\n);\n");
2148
2149 if (dopt->binary_upgrade)
2150 binary_upgrade_extension_member(q, &tyinfo->dobj,
2151 "TYPE", qtypname,
2152 tyinfo->dobj.namespace->dobj.name);
2153
2154 if (tyinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
2155 ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId,
2156 tyinfo->dobj.name,
2157 tyinfo->dobj.namespace->dobj.name,
2158 NULL,
2159 tyinfo->rolname,
2160 "TYPE", SECTION_PRE_DATA,
2161 q->data, delq->data, NULL,
2162 NULL, 0,
2163 NULL, NULL);
2164
2165 /* Dump Type Comments and Security Labels */
2166 if (tyinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
2167 dumpComment(fout, "TYPE", qtypname,
2168 tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
2169 tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
2170
2171 if (tyinfo->dobj.dump & DUMP_COMPONENT_SECLABEL)
2172 dumpSecLabel(fout, "TYPE", qtypname,
2173 tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
2174 tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
2175
2176 if (tyinfo->dobj.dump & DUMP_COMPONENT_ACL)
2177 dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
2178 qtypname, NULL,
2179 tyinfo->dobj.namespace->dobj.name,
2180 tyinfo->rolname, tyinfo->typacl, tyinfo->rtypacl,
2181 tyinfo->inittypacl, tyinfo->initrtypacl);
2182
2183 PQclear(res);
2184 destroyPQExpBuffer(q);
2185 destroyPQExpBuffer(delq);
2186 destroyPQExpBuffer(query);
2187 free(qtypname);
2188 free(qualtypname);
2189}
2190
2191/*
2192 * dumpUndefinedType
2193 * writes out to fout the queries to recreate a !typisdefined type
2194 *
2195 * This is a shell type, but we use different terminology to distinguish
2196 * this case from where we have to emit a shell type definition to break
2197 * circular dependencies. An undefined type shouldn't ever have anything
2198 * depending on it.
2199 */
2200static void
2201=====================================================================
2202Found a 47 line (291 tokens) duplication in the following files:
2203Starting at line 10082 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_dump.c
2204Starting at line 10209 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_dump.c
2205Starting at line 10564 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_dump.c
2206
2207 if (dopt->binary_upgrade)
2208 binary_upgrade_extension_member(q, &tyinfo->dobj,
2209 "TYPE", qtypname,
2210 tyinfo->dobj.namespace->dobj.name);
2211
2212 if (tyinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
2213 ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId,
2214 tyinfo->dobj.name,
2215 tyinfo->dobj.namespace->dobj.name,
2216 NULL,
2217 tyinfo->rolname,
2218 "TYPE", SECTION_PRE_DATA,
2219 q->data, delq->data, NULL,
2220 NULL, 0,
2221 NULL, NULL);
2222
2223 /* Dump Type Comments and Security Labels */
2224 if (tyinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
2225 dumpComment(fout, "TYPE", qtypname,
2226 tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
2227 tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
2228
2229 if (tyinfo->dobj.dump & DUMP_COMPONENT_SECLABEL)
2230 dumpSecLabel(fout, "TYPE", qtypname,
2231 tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
2232 tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
2233
2234 if (tyinfo->dobj.dump & DUMP_COMPONENT_ACL)
2235 dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
2236 qtypname, NULL,
2237 tyinfo->dobj.namespace->dobj.name,
2238 tyinfo->rolname, tyinfo->typacl, tyinfo->rtypacl,
2239 tyinfo->inittypacl, tyinfo->initrtypacl);
2240
2241 PQclear(res);
2242 destroyPQExpBuffer(q);
2243 destroyPQExpBuffer(delq);
2244 destroyPQExpBuffer(query);
2245 free(qtypname);
2246 free(qualtypname);
2247}
2248
2249/*
2250 * dumpRangeType
2251 * writes out to fout the queries to recreate a user-defined range type
2252 */
2253static void
2254=====================================================================
2255Found a 81 line (286 tokens) duplication in the following files:
2256Starting at line 181 of /home/shackle/pggit/postgresql/src/backend/utils/time/tqual.c
2257Starting at line 748 of /home/shackle/pggit/postgresql/src/backend/utils/time/tqual.c
2258
2259 Assert(htup->t_tableOid != InvalidOid);
2260
2261 if (!HeapTupleHeaderXminCommitted(tuple))
2262 {
2263 if (HeapTupleHeaderXminInvalid(tuple))
2264 return false;
2265
2266 /* Used by pre-9.0 binary upgrades */
2267 if (tuple->t_infomask & HEAP_MOVED_OFF)
2268 {
2269 TransactionId xvac = HeapTupleHeaderGetXvac(tuple);
2270
2271 if (TransactionIdIsCurrentTransactionId(xvac))
2272 return false;
2273 if (!TransactionIdIsInProgress(xvac))
2274 {
2275 if (TransactionIdDidCommit(xvac))
2276 {
2277 SetHintBits(tuple, buffer, HEAP_XMIN_INVALID,
2278 InvalidTransactionId);
2279 return false;
2280 }
2281 SetHintBits(tuple, buffer, HEAP_XMIN_COMMITTED,
2282 InvalidTransactionId);
2283 }
2284 }
2285 /* Used by pre-9.0 binary upgrades */
2286 else if (tuple->t_infomask & HEAP_MOVED_IN)
2287 {
2288 TransactionId xvac = HeapTupleHeaderGetXvac(tuple);
2289
2290 if (!TransactionIdIsCurrentTransactionId(xvac))
2291 {
2292 if (TransactionIdIsInProgress(xvac))
2293 return false;
2294 if (TransactionIdDidCommit(xvac))
2295 SetHintBits(tuple, buffer, HEAP_XMIN_COMMITTED,
2296 InvalidTransactionId);
2297 else
2298 {
2299 SetHintBits(tuple, buffer, HEAP_XMIN_INVALID,
2300 InvalidTransactionId);
2301 return false;
2302 }
2303 }
2304 }
2305 else if (TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetRawXmin(tuple)))
2306 {
2307 if (tuple->t_infomask & HEAP_XMAX_INVALID) /* xid invalid */
2308 return true;
2309
2310 if (HEAP_XMAX_IS_LOCKED_ONLY(tuple->t_infomask)) /* not deleter */
2311 return true;
2312
2313 if (tuple->t_infomask & HEAP_XMAX_IS_MULTI)
2314 {
2315 TransactionId xmax;
2316
2317 xmax = HeapTupleGetUpdateXid(tuple);
2318
2319 /* not LOCKED_ONLY, so it has to have an xmax */
2320 Assert(TransactionIdIsValid(xmax));
2321
2322 /* updating subtransaction must have aborted */
2323 if (!TransactionIdIsCurrentTransactionId(xmax))
2324 return true;
2325 else
2326 return false;
2327 }
2328
2329 if (!TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetRawXmax(tuple)))
2330 {
2331 /* deleting subtransaction must have aborted */
2332 SetHintBits(tuple, buffer, HEAP_XMAX_INVALID,
2333 InvalidTransactionId);
2334 return true;
2335 }
2336
2337 return false;
2338 }
2339 else if (TransactionIdIsInProgress(HeapTupleHeaderGetRawXmin(tuple)))
2340=====================================================================
2341Found a 53 line (285 tokens) duplication in the following files:
2342Starting at line 359 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/compat_informix-describe.c
2343Starting at line 357 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-describe.c
2344
2345 { ECPGdescribe(__LINE__, 1, 0, NULL, "st_id2",
2346 ECPGt_sqlda, &sqlda3, 0L, 0L, 0L,
2347 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
2348#line 151 "describe.pgc"
2349
2350
2351 if (sqlda1 == NULL || sqlda2 == NULL || sqlda3 == NULL)
2352 exit(1);
2353
2354 strcpy(msg, "get descriptor");
2355 { ECPGget_desc_header(__LINE__, "desc1", &(count1));
2356
2357#line 157 "describe.pgc"
2358
2359if (sqlca.sqlcode < 0) exit (1);}
2360#line 157 "describe.pgc"
2361
2362 { ECPGget_desc_header(__LINE__, "desc1", &(count2));
2363
2364#line 158 "describe.pgc"
2365
2366if (sqlca.sqlcode < 0) exit (1);}
2367#line 158 "describe.pgc"
2368
2369
2370 if (!( count1 == count2 &&
2371 count1 == sqlda1->sqld &&
2372 count1 == sqlda2->sqld &&
2373 count1 == sqlda3->sqld))
2374 exit(1);
2375
2376 for (i = 1; i <= count1; i++)
2377 {
2378 { ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
2379 ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
2380
2381#line 168 "describe.pgc"
2382
2383if (sqlca.sqlcode < 0) exit (1);}
2384#line 168 "describe.pgc"
2385
2386 { ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
2387 ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
2388
2389#line 169 "describe.pgc"
2390
2391if (sqlca.sqlcode < 0) exit (1);}
2392#line 169 "describe.pgc"
2393
2394 printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
2395 "sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n",
2396 i, field_name1, field_name2,
2397 sqlda1->sqlvar[i-1].sqlname,
2398=====================================================================
2399Found a 61 line (281 tokens) duplication in the following files:
2400Starting at line 34 of /home/shackle/pggit/postgresql/src/backend/access/gin/ginvalidate.c
2401Starting at line 34 of /home/shackle/pggit/postgresql/src/backend/access/gist/gistvalidate.c
2402
2403ginvalidate(Oid opclassoid)
2404{
2405 bool result = true;
2406 HeapTuple classtup;
2407 Form_pg_opclass classform;
2408 Oid opfamilyoid;
2409 Oid opcintype;
2410 Oid opckeytype;
2411 char *opclassname;
2412 HeapTuple familytup;
2413 Form_pg_opfamily familyform;
2414 char *opfamilyname;
2415 CatCList *proclist,
2416 *oprlist;
2417 List *grouplist;
2418 OpFamilyOpFuncGroup *opclassgroup;
2419 int i;
2420 ListCell *lc;
2421
2422 /* Fetch opclass information */
2423 classtup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclassoid));
2424 if (!HeapTupleIsValid(classtup))
2425 elog(ERROR, "cache lookup failed for operator class %u", opclassoid);
2426 classform = (Form_pg_opclass) GETSTRUCT(classtup);
2427
2428 opfamilyoid = classform->opcfamily;
2429 opcintype = classform->opcintype;
2430 opckeytype = classform->opckeytype;
2431 if (!OidIsValid(opckeytype))
2432 opckeytype = opcintype;
2433 opclassname = NameStr(classform->opcname);
2434
2435 /* Fetch opfamily information */
2436 familytup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfamilyoid));
2437 if (!HeapTupleIsValid(familytup))
2438 elog(ERROR, "cache lookup failed for operator family %u", opfamilyoid);
2439 familyform = (Form_pg_opfamily) GETSTRUCT(familytup);
2440
2441 opfamilyname = NameStr(familyform->opfname);
2442
2443 /* Fetch all operators and support functions of the opfamily */
2444 oprlist = SearchSysCacheList1(AMOPSTRATEGY, ObjectIdGetDatum(opfamilyoid));
2445 proclist = SearchSysCacheList1(AMPROCNUM, ObjectIdGetDatum(opfamilyoid));
2446
2447 /* Check individual support functions */
2448 for (i = 0; i < proclist->n_members; i++)
2449 {
2450 HeapTuple proctup = &proclist->members[i]->tuple;
2451 Form_pg_amproc procform = (Form_pg_amproc) GETSTRUCT(proctup);
2452 bool ok;
2453
2454 /*
2455 * All GIN support functions should be registered with matching
2456 * left/right types
2457 */
2458 if (procform->amproclefttype != procform->amprocrighttype)
2459 {
2460 ereport(INFO,
2461 (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2462 errmsg("operator family \"%s\" of access method %s contains support function %s with different left and right input types",
2463 opfamilyname, "gin",
2464=====================================================================
2465Found a 53 line (279 tokens) duplication in the following files:
2466Starting at line 117 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-array_of_struct.c
2467Starting at line 121 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-pointer_to_struct.c
2468
2469 struct varchar_5 { int len; char arr[ 50 ]; } onlyname [ 2 ] ;
2470/* exec sql end declare section */
2471#line 46 "array_of_struct.pgc"
2472
2473
2474 ECPGdebug(1, stderr);
2475
2476 { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0);
2477#line 50 "array_of_struct.pgc"
2478
2479if (sqlca.sqlwarn[0] == 'W') sqlprint();
2480#line 50 "array_of_struct.pgc"
2481
2482if (sqlca.sqlcode < 0) sqlprint();}
2483#line 50 "array_of_struct.pgc"
2484
2485
2486 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table customers ( c varchar ( 50 ) , p int )", ECPGt_EOIT, ECPGt_EORT);
2487#line 52 "array_of_struct.pgc"
2488
2489if (sqlca.sqlwarn[0] == 'W') sqlprint();
2490#line 52 "array_of_struct.pgc"
2491
2492if (sqlca.sqlcode < 0) sqlprint();}
2493#line 52 "array_of_struct.pgc"
2494
2495 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into customers values ( 'John Doe' , '12345' )", ECPGt_EOIT, ECPGt_EORT);
2496#line 53 "array_of_struct.pgc"
2497
2498if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint();
2499#line 53 "array_of_struct.pgc"
2500
2501if (sqlca.sqlwarn[0] == 'W') sqlprint();
2502#line 53 "array_of_struct.pgc"
2503
2504if (sqlca.sqlcode < 0) sqlprint();}
2505#line 53 "array_of_struct.pgc"
2506
2507 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into customers values ( 'Jane Doe' , '67890' )", ECPGt_EOIT, ECPGt_EORT);
2508#line 54 "array_of_struct.pgc"
2509
2510if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint();
2511#line 54 "array_of_struct.pgc"
2512
2513if (sqlca.sqlwarn[0] == 'W') sqlprint();
2514#line 54 "array_of_struct.pgc"
2515
2516if (sqlca.sqlcode < 0) sqlprint();}
2517#line 54 "array_of_struct.pgc"
2518
2519
2520 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select * from customers limit 2", ECPGt_EOIT,
2521 ECPGt_varchar,&(custs1->name),(long)50,(long)10,sizeof( customer ),
2522=====================================================================
2523Found a 60 line (277 tokens) duplication in the following files:
2524Starting at line 33 of /home/shackle/pggit/postgresql/contrib/bloom/blvalidate.c
2525Starting at line 34 of /home/shackle/pggit/postgresql/src/backend/access/gin/ginvalidate.c
2526Starting at line 34 of /home/shackle/pggit/postgresql/src/backend/access/gist/gistvalidate.c
2527
2528blvalidate(Oid opclassoid)
2529{
2530 bool result = true;
2531 HeapTuple classtup;
2532 Form_pg_opclass classform;
2533 Oid opfamilyoid;
2534 Oid opcintype;
2535 Oid opckeytype;
2536 char *opclassname;
2537 HeapTuple familytup;
2538 Form_pg_opfamily familyform;
2539 char *opfamilyname;
2540 CatCList *proclist,
2541 *oprlist;
2542 List *grouplist;
2543 OpFamilyOpFuncGroup *opclassgroup;
2544 int i;
2545 ListCell *lc;
2546
2547 /* Fetch opclass information */
2548 classtup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclassoid));
2549 if (!HeapTupleIsValid(classtup))
2550 elog(ERROR, "cache lookup failed for operator class %u", opclassoid);
2551 classform = (Form_pg_opclass) GETSTRUCT(classtup);
2552
2553 opfamilyoid = classform->opcfamily;
2554 opcintype = classform->opcintype;
2555 opckeytype = classform->opckeytype;
2556 if (!OidIsValid(opckeytype))
2557 opckeytype = opcintype;
2558 opclassname = NameStr(classform->opcname);
2559
2560 /* Fetch opfamily information */
2561 familytup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfamilyoid));
2562 if (!HeapTupleIsValid(familytup))
2563 elog(ERROR, "cache lookup failed for operator family %u", opfamilyoid);
2564 familyform = (Form_pg_opfamily) GETSTRUCT(familytup);
2565
2566 opfamilyname = NameStr(familyform->opfname);
2567
2568 /* Fetch all operators and support functions of the opfamily */
2569 oprlist = SearchSysCacheList1(AMOPSTRATEGY, ObjectIdGetDatum(opfamilyoid));
2570 proclist = SearchSysCacheList1(AMPROCNUM, ObjectIdGetDatum(opfamilyoid));
2571
2572 /* Check individual support functions */
2573 for (i = 0; i < proclist->n_members; i++)
2574 {
2575 HeapTuple proctup = &proclist->members[i]->tuple;
2576 Form_pg_amproc procform = (Form_pg_amproc) GETSTRUCT(proctup);
2577 bool ok;
2578
2579 /*
2580 * All bloom support functions should be registered with matching
2581 * left/right types
2582 */
2583 if (procform->amproclefttype != procform->amprocrighttype)
2584 {
2585 ereport(INFO,
2586 (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2587 errmsg("bloom opfamily %s contains support procedure %s with cross-type registration",
2588=====================================================================
2589Found a 58 line (273 tokens) duplication in the following files:
2590Starting at line 6667 of /home/shackle/pggit/postgresql/src/backend/utils/misc/guc.c
2591Starting at line 6757 of /home/shackle/pggit/postgresql/src/backend/utils/misc/guc.c
2592Starting at line 6847 of /home/shackle/pggit/postgresql/src/backend/utils/misc/guc.c
2593Starting at line 7050 of /home/shackle/pggit/postgresql/src/backend/utils/misc/guc.c
2594
2595 if (!call_bool_check_hook(conf, &newval, &newextra,
2596 source, elevel))
2597 return 0;
2598 }
2599 else
2600 {
2601 newval = conf->reset_val;
2602 newextra = conf->reset_extra;
2603 source = conf->gen.reset_source;
2604 context = conf->gen.reset_scontext;
2605 }
2606
2607 if (prohibitValueChange)
2608 {
2609 if (*conf->variable != newval)
2610 {
2611 record->status |= GUC_PENDING_RESTART;
2612 ereport(elevel,
2613 (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
2614 errmsg("parameter \"%s\" cannot be changed without restarting the server",
2615 name)));
2616 return 0;
2617 }
2618 record->status &= ~GUC_PENDING_RESTART;
2619 return -1;
2620 }
2621
2622 if (changeVal)
2623 {
2624 /* Save old value to support transaction abort */
2625 if (!makeDefault)
2626 push_old_value(&conf->gen, action);
2627
2628 if (conf->assign_hook)
2629 conf->assign_hook(newval, newextra);
2630 *conf->variable = newval;
2631 set_extra_field(&conf->gen, &conf->gen.extra,
2632 newextra);
2633 conf->gen.source = source;
2634 conf->gen.scontext = context;
2635 }
2636 if (makeDefault)
2637 {
2638 GucStack *stack;
2639
2640 if (conf->gen.reset_source <= source)
2641 {
2642 conf->reset_val = newval;
2643 set_extra_field(&conf->gen, &conf->reset_extra,
2644 newextra);
2645 conf->gen.reset_source = source;
2646 conf->gen.reset_scontext = context;
2647 }
2648 for (stack = conf->gen.stack; stack; stack = stack->prev)
2649 {
2650 if (stack->source <= source)
2651 {
2652 stack->prior.val.boolval = newval;
2653=====================================================================
2654Found a 39 line (272 tokens) duplication in the following files:
2655Starting at line 10207 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_dump.c
2656Starting at line 10562 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_dump.c
2657Starting at line 10941 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_dump.c
2658
2659 appendPQExpBufferStr(q, "\n);\n");
2660
2661 if (dopt->binary_upgrade)
2662 binary_upgrade_extension_member(q, &tyinfo->dobj,
2663 "TYPE", qtypname,
2664 tyinfo->dobj.namespace->dobj.name);
2665
2666 if (tyinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
2667 ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId,
2668 tyinfo->dobj.name,
2669 tyinfo->dobj.namespace->dobj.name,
2670 NULL,
2671 tyinfo->rolname,
2672 "TYPE", SECTION_PRE_DATA,
2673 q->data, delq->data, NULL,
2674 NULL, 0,
2675 NULL, NULL);
2676
2677 /* Dump Type Comments and Security Labels */
2678 if (tyinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
2679 dumpComment(fout, "TYPE", qtypname,
2680 tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
2681 tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
2682
2683 if (tyinfo->dobj.dump & DUMP_COMPONENT_SECLABEL)
2684 dumpSecLabel(fout, "TYPE", qtypname,
2685 tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
2686 tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
2687
2688 if (tyinfo->dobj.dump & DUMP_COMPONENT_ACL)
2689 dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
2690 qtypname, NULL,
2691 tyinfo->dobj.namespace->dobj.name,
2692 tyinfo->rolname, tyinfo->typacl, tyinfo->rtypacl,
2693 tyinfo->inittypacl, tyinfo->initrtypacl);
2694
2695 PQclear(res);
2696 destroyPQExpBuffer(q);
2697 destroyPQExpBuffer(delq);
2698=====================================================================
2699Found a 52 line (271 tokens) duplication in the following files:
2700Starting at line 276 of /home/shackle/pggit/postgresql/src/backend/utils/adt/network_selfuncs.c
2701Starting at line 406 of /home/shackle/pggit/postgresql/src/backend/utils/adt/network_selfuncs.c
2702
2703 int mcv1_length = 0,
2704 mcv2_length = 0;
2705 AttStatsSlot mcv1_slot;
2706 AttStatsSlot mcv2_slot;
2707 AttStatsSlot hist1_slot;
2708 AttStatsSlot hist2_slot;
2709
2710 if (HeapTupleIsValid(vardata1->statsTuple))
2711 {
2712 stats = (Form_pg_statistic) GETSTRUCT(vardata1->statsTuple);
2713 nullfrac1 = stats->stanullfrac;
2714
2715 mcv1_exists = get_attstatsslot(&mcv1_slot, vardata1->statsTuple,
2716 STATISTIC_KIND_MCV, InvalidOid,
2717 ATTSTATSSLOT_VALUES | ATTSTATSSLOT_NUMBERS);
2718 hist1_exists = get_attstatsslot(&hist1_slot, vardata1->statsTuple,
2719 STATISTIC_KIND_HISTOGRAM, InvalidOid,
2720 ATTSTATSSLOT_VALUES);
2721 /* Arbitrarily limit number of MCVs considered */
2722 mcv1_length = Min(mcv1_slot.nvalues, MAX_CONSIDERED_ELEMS);
2723 if (mcv1_exists)
2724 sumcommon1 = mcv_population(mcv1_slot.numbers, mcv1_length);
2725 }
2726 else
2727 {
2728 memset(&mcv1_slot, 0, sizeof(mcv1_slot));
2729 memset(&hist1_slot, 0, sizeof(hist1_slot));
2730 }
2731
2732 if (HeapTupleIsValid(vardata2->statsTuple))
2733 {
2734 stats = (Form_pg_statistic) GETSTRUCT(vardata2->statsTuple);
2735 nullfrac2 = stats->stanullfrac;
2736
2737 mcv2_exists = get_attstatsslot(&mcv2_slot, vardata2->statsTuple,
2738 STATISTIC_KIND_MCV, InvalidOid,
2739 ATTSTATSSLOT_VALUES | ATTSTATSSLOT_NUMBERS);
2740 hist2_exists = get_attstatsslot(&hist2_slot, vardata2->statsTuple,
2741 STATISTIC_KIND_HISTOGRAM, InvalidOid,
2742 ATTSTATSSLOT_VALUES);
2743 /* Arbitrarily limit number of MCVs considered */
2744 mcv2_length = Min(mcv2_slot.nvalues, MAX_CONSIDERED_ELEMS);
2745 if (mcv2_exists)
2746 sumcommon2 = mcv_population(mcv2_slot.numbers, mcv2_length);
2747 }
2748 else
2749 {
2750 memset(&mcv2_slot, 0, sizeof(mcv2_slot));
2751 memset(&hist2_slot, 0, sizeof(hist2_slot));
2752 }
2753
2754 opr_codenum = inet_opr_codenum(operator);
2755=====================================================================
2756Found a 37 line (270 tokens) duplication in the following files:
2757Starting at line 10082 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_dump.c
2758Starting at line 10943 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_dump.c
2759
2760 if (dopt->binary_upgrade)
2761 binary_upgrade_extension_member(q, &tyinfo->dobj,
2762 "TYPE", qtypname,
2763 tyinfo->dobj.namespace->dobj.name);
2764
2765 if (tyinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
2766 ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId,
2767 tyinfo->dobj.name,
2768 tyinfo->dobj.namespace->dobj.name,
2769 NULL,
2770 tyinfo->rolname,
2771 "TYPE", SECTION_PRE_DATA,
2772 q->data, delq->data, NULL,
2773 NULL, 0,
2774 NULL, NULL);
2775
2776 /* Dump Type Comments and Security Labels */
2777 if (tyinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
2778 dumpComment(fout, "TYPE", qtypname,
2779 tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
2780 tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
2781
2782 if (tyinfo->dobj.dump & DUMP_COMPONENT_SECLABEL)
2783 dumpSecLabel(fout, "TYPE", qtypname,
2784 tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
2785 tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
2786
2787 if (tyinfo->dobj.dump & DUMP_COMPONENT_ACL)
2788 dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
2789 qtypname, NULL,
2790 tyinfo->dobj.namespace->dobj.name,
2791 tyinfo->rolname, tyinfo->typacl, tyinfo->rtypacl,
2792 tyinfo->inittypacl, tyinfo->initrtypacl);
2793
2794 PQclear(res);
2795 destroyPQExpBuffer(q);
2796 destroyPQExpBuffer(delq);
2797=====================================================================
2798Found a 43 line (269 tokens) duplication in the following files:
2799Starting at line 1190 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/ecpglib/execute.c
2800Starting at line 1245 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/ecpglib/execute.c
2801
2802 for (i = 0; i < sqlda->sqld; i++)
2803 {
2804 if (i + 1 == desc_counter)
2805 {
2806 desc_inlist.type = sqlda->sqlvar[i].sqltype;
2807 desc_inlist.value = sqlda->sqlvar[i].sqldata;
2808 desc_inlist.pointer = &(sqlda->sqlvar[i].sqldata);
2809 switch (desc_inlist.type)
2810 {
2811 case ECPGt_char:
2812 case ECPGt_varchar:
2813 desc_inlist.varcharsize = strlen(sqlda->sqlvar[i].sqldata);
2814 break;
2815 default:
2816 desc_inlist.varcharsize = 0;
2817 break;
2818 }
2819 desc_inlist.arrsize = 1;
2820 desc_inlist.offset = 0;
2821 if (sqlda->sqlvar[i].sqlind)
2822 {
2823 desc_inlist.ind_type = ECPGt_short;
2824 /* ECPG expects indicator value < 0 */
2825 if (*(sqlda->sqlvar[i].sqlind))
2826 *(sqlda->sqlvar[i].sqlind) = -1;
2827 desc_inlist.ind_value = sqlda->sqlvar[i].sqlind;
2828 desc_inlist.ind_pointer = &(sqlda->sqlvar[i].sqlind);
2829 desc_inlist.ind_varcharsize = desc_inlist.ind_arrsize = 1;
2830 desc_inlist.ind_offset = 0;
2831 }
2832 else
2833 {
2834 desc_inlist.ind_type = ECPGt_NO_INDICATOR;
2835 desc_inlist.ind_value = desc_inlist.ind_pointer = NULL;
2836 desc_inlist.ind_varcharsize = desc_inlist.ind_arrsize = desc_inlist.ind_offset = 0;
2837 }
2838 if (!ecpg_store_input(stmt->lineno, stmt->force_indicator, &desc_inlist, &tobeinserted, false))
2839 return false;
2840
2841 break;
2842 }
2843 }
2844 if (sqlda->sqld == desc_counter)
2845=====================================================================
2846Found a 50 line (267 tokens) duplication in the following files:
2847Starting at line 17 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/include/pgtypes_numeric.h
2848Starting at line 66 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-sqlda.c
2849Starting at line 44 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-outofscope.c
2850
2851typedef unsigned char NumericDigit;
2852typedef struct
2853{
2854 int ndigits; /* number of digits in digits[] - can be 0! */
2855 int weight; /* weight of first digit */
2856 int rscale; /* result scale */
2857 int dscale; /* display scale */
2858 int sign; /* NUMERIC_POS, NUMERIC_NEG, or NUMERIC_NAN */
2859 NumericDigit *buf; /* start of alloc'd space for digits[] */
2860 NumericDigit *digits; /* decimal digits */
2861} numeric;
2862
2863typedef struct
2864{
2865 int ndigits; /* number of digits in digits[] - can be 0! */
2866 int weight; /* weight of first digit */
2867 int rscale; /* result scale */
2868 int dscale; /* display scale */
2869 int sign; /* NUMERIC_POS, NUMERIC_NEG, or NUMERIC_NAN */
2870 NumericDigit digits[DECSIZE]; /* decimal digits */
2871} decimal;
2872
2873#ifdef __cplusplus
2874extern "C"
2875{
2876#endif
2877
2878numeric *PGTYPESnumeric_new(void);
2879decimal *PGTYPESdecimal_new(void);
2880void PGTYPESnumeric_free(numeric *);
2881void PGTYPESdecimal_free(decimal *);
2882numeric *PGTYPESnumeric_from_asc(char *, char **);
2883char *PGTYPESnumeric_to_asc(numeric *, int);
2884int PGTYPESnumeric_add(numeric *, numeric *, numeric *);
2885int PGTYPESnumeric_sub(numeric *, numeric *, numeric *);
2886int PGTYPESnumeric_mul(numeric *, numeric *, numeric *);
2887int PGTYPESnumeric_div(numeric *, numeric *, numeric *);
2888int PGTYPESnumeric_cmp(numeric *, numeric *);
2889int PGTYPESnumeric_from_int(signed int, numeric *);
2890int PGTYPESnumeric_from_long(signed long int, numeric *);
2891int PGTYPESnumeric_copy(numeric *, numeric *);
2892int PGTYPESnumeric_from_double(double, numeric *);
2893int PGTYPESnumeric_to_double(numeric *, double *);
2894int PGTYPESnumeric_to_int(numeric *, int *);
2895int PGTYPESnumeric_to_long(numeric *, long *);
2896int PGTYPESnumeric_to_decimal(numeric *, decimal *);
2897int PGTYPESnumeric_from_decimal(decimal *, numeric *);
2898
2899#ifdef __cplusplus
2900}
2901=====================================================================
2902Found a 36 line (262 tokens) duplication in the following files:
2903Starting at line 10279 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_dump.c
2904Starting at line 10941 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_dump.c
2905
2906 appendPQExpBuffer(q, "CREATE TYPE %s;\n",
2907 qualtypname);
2908
2909 if (dopt->binary_upgrade)
2910 binary_upgrade_extension_member(q, &tyinfo->dobj,
2911 "TYPE", qtypname,
2912 tyinfo->dobj.namespace->dobj.name);
2913
2914 if (tyinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
2915 ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId,
2916 tyinfo->dobj.name,
2917 tyinfo->dobj.namespace->dobj.name,
2918 NULL,
2919 tyinfo->rolname,
2920 "TYPE", SECTION_PRE_DATA,
2921 q->data, delq->data, NULL,
2922 NULL, 0,
2923 NULL, NULL);
2924
2925 /* Dump Type Comments and Security Labels */
2926 if (tyinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
2927 dumpComment(fout, "TYPE", qtypname,
2928 tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
2929 tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
2930
2931 if (tyinfo->dobj.dump & DUMP_COMPONENT_SECLABEL)
2932 dumpSecLabel(fout, "TYPE", qtypname,
2933 tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
2934 tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
2935
2936 if (tyinfo->dobj.dump & DUMP_COMPONENT_ACL)
2937 dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
2938 qtypname, NULL,
2939 tyinfo->dobj.namespace->dobj.name,
2940 tyinfo->rolname, tyinfo->typacl, tyinfo->rtypacl,
2941 tyinfo->inittypacl, tyinfo->initrtypacl);
2942=====================================================================
2943Found a 35 line (260 tokens) duplication in the following files:
2944Starting at line 10207 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_dump.c
2945Starting at line 10280 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_dump.c
2946Starting at line 10562 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_dump.c
2947
2948 appendPQExpBufferStr(q, "\n);\n");
2949
2950 if (dopt->binary_upgrade)
2951 binary_upgrade_extension_member(q, &tyinfo->dobj,
2952 "TYPE", qtypname,
2953 tyinfo->dobj.namespace->dobj.name);
2954
2955 if (tyinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
2956 ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId,
2957 tyinfo->dobj.name,
2958 tyinfo->dobj.namespace->dobj.name,
2959 NULL,
2960 tyinfo->rolname,
2961 "TYPE", SECTION_PRE_DATA,
2962 q->data, delq->data, NULL,
2963 NULL, 0,
2964 NULL, NULL);
2965
2966 /* Dump Type Comments and Security Labels */
2967 if (tyinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
2968 dumpComment(fout, "TYPE", qtypname,
2969 tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
2970 tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
2971
2972 if (tyinfo->dobj.dump & DUMP_COMPONENT_SECLABEL)
2973 dumpSecLabel(fout, "TYPE", qtypname,
2974 tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
2975 tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
2976
2977 if (tyinfo->dobj.dump & DUMP_COMPONENT_ACL)
2978 dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
2979 qtypname, NULL,
2980 tyinfo->dobj.namespace->dobj.name,
2981 tyinfo->rolname, tyinfo->typacl, tyinfo->rtypacl,
2982 tyinfo->inittypacl, tyinfo->initrtypacl);
2983=====================================================================
2984Found a 33 line (258 tokens) duplication in the following files:
2985Starting at line 10082 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_dump.c
2986Starting at line 10282 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_dump.c
2987
2988 if (dopt->binary_upgrade)
2989 binary_upgrade_extension_member(q, &tyinfo->dobj,
2990 "TYPE", qtypname,
2991 tyinfo->dobj.namespace->dobj.name);
2992
2993 if (tyinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
2994 ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId,
2995 tyinfo->dobj.name,
2996 tyinfo->dobj.namespace->dobj.name,
2997 NULL,
2998 tyinfo->rolname,
2999 "TYPE", SECTION_PRE_DATA,
3000 q->data, delq->data, NULL,
3001 NULL, 0,
3002 NULL, NULL);
3003
3004 /* Dump Type Comments and Security Labels */
3005 if (tyinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
3006 dumpComment(fout, "TYPE", qtypname,
3007 tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
3008 tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
3009
3010 if (tyinfo->dobj.dump & DUMP_COMPONENT_SECLABEL)
3011 dumpSecLabel(fout, "TYPE", qtypname,
3012 tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
3013 tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
3014
3015 if (tyinfo->dobj.dump & DUMP_COMPONENT_ACL)
3016 dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
3017 qtypname, NULL,
3018 tyinfo->dobj.namespace->dobj.name,
3019 tyinfo->rolname, tyinfo->typacl, tyinfo->rtypacl,
3020 tyinfo->inittypacl, tyinfo->initrtypacl);
3021=====================================================================
3022Found a 53 line (257 tokens) duplication in the following files:
3023Starting at line 310 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
3024Starting at line 657 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
3025
3026 int ncolumns;
3027 int i;
3028 Datum *values;
3029 bool *nulls;
3030 StringInfoData buf;
3031
3032 check_stack_depth(); /* recurses for record-type columns */
3033
3034 /* Extract type info from the tuple itself */
3035 tupType = HeapTupleHeaderGetTypeId(rec);
3036 tupTypmod = HeapTupleHeaderGetTypMod(rec);
3037 tupdesc = lookup_rowtype_tupdesc(tupType, tupTypmod);
3038 ncolumns = tupdesc->natts;
3039
3040 /* Build a temporary HeapTuple control structure */
3041 tuple.t_len = HeapTupleHeaderGetDatumLength(rec);
3042 ItemPointerSetInvalid(&(tuple.t_self));
3043 tuple.t_tableOid = InvalidOid;
3044 tuple.t_data = rec;
3045
3046 /*
3047 * We arrange to look up the needed I/O info just once per series of
3048 * calls, assuming the record type doesn't change underneath us.
3049 */
3050 my_extra = (RecordIOData *) fcinfo->flinfo->fn_extra;
3051 if (my_extra == NULL ||
3052 my_extra->ncolumns != ncolumns)
3053 {
3054 fcinfo->flinfo->fn_extra =
3055 MemoryContextAlloc(fcinfo->flinfo->fn_mcxt,
3056 offsetof(RecordIOData, columns) +
3057 ncolumns * sizeof(ColumnIOData));
3058 my_extra = (RecordIOData *) fcinfo->flinfo->fn_extra;
3059 my_extra->record_type = InvalidOid;
3060 my_extra->record_typmod = 0;
3061 }
3062
3063 if (my_extra->record_type != tupType ||
3064 my_extra->record_typmod != tupTypmod)
3065 {
3066 MemSet(my_extra, 0,
3067 offsetof(RecordIOData, columns) +
3068 ncolumns * sizeof(ColumnIOData));
3069 my_extra->record_type = tupType;
3070 my_extra->record_typmod = tupTypmod;
3071 my_extra->ncolumns = ncolumns;
3072 }
3073
3074 values = (Datum *) palloc(ncolumns * sizeof(Datum));
3075 nulls = (bool *) palloc(ncolumns * sizeof(bool));
3076
3077 /* Break down the tuple into fields */
3078 heap_deform_tuple(&tuple, tupdesc, values, nulls);
3079=====================================================================
3080Found a 8 line (255 tokens) duplication in the following files:
3081Starting at line 120 of /home/shackle/pggit/postgresql/src/backend/access/heap/visibilitymap.c
3082Starting at line 128 of /home/shackle/pggit/postgresql/src/backend/access/heap/visibilitymap.c
3083
3084 0, 1, 0, 1, 1, 2, 1, 2, 0, 1, 0, 1, 1, 2, 1, 2,
3085 1, 2, 1, 2, 2, 3, 2, 3, 1, 2, 1, 2, 2, 3, 2, 3,
3086 0, 1, 0, 1, 1, 2, 1, 2, 0, 1, 0, 1, 1, 2, 1, 2,
3087 1, 2, 1, 2, 2, 3, 2, 3, 1, 2, 1, 2, 2, 3, 2, 3,
3088 1, 2, 1, 2, 2, 3, 2, 3, 1, 2, 1, 2, 2, 3, 2, 3,
3089 2, 3, 2, 3, 3, 4, 3, 4, 2, 3, 2, 3, 3, 4, 3, 4,
3090 1, 2, 1, 2, 2, 3, 2, 3, 1, 2, 1, 2, 2, 3, 2, 3,
3091 2, 3, 2, 3, 3, 4, 3, 4, 2, 3, 2, 3, 3, 4, 3, 4,
3092=====================================================================
3093Found a 8 line (254 tokens) duplication in the following files:
3094Starting at line 72 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
3095Starting at line 80 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
3096
3097 0, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
3098 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
3099 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
3100 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
3101 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
3102 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
3103 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
3104 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
3105=====================================================================
3106Found a 66 line (245 tokens) duplication in the following files:
3107Starting at line 148 of /home/shackle/pggit/postgresql/src/backend/executor/execReplication.c
3108Starting at line 315 of /home/shackle/pggit/postgresql/src/backend/executor/execReplication.c
3109
3110 found = true;
3111 ExecStoreHeapTuple(scantuple, outslot, false);
3112 ExecMaterializeSlot(outslot);
3113
3114 xwait = TransactionIdIsValid(snap.xmin) ?
3115 snap.xmin : snap.xmax;
3116
3117 /*
3118 * If the tuple is locked, wait for locking transaction to finish and
3119 * retry.
3120 */
3121 if (TransactionIdIsValid(xwait))
3122 {
3123 XactLockTableWait(xwait, NULL, NULL, XLTW_None);
3124 goto retry;
3125 }
3126 }
3127
3128 /* Found tuple, try to lock it in the lockmode. */
3129 if (found)
3130 {
3131 Buffer buf;
3132 HeapUpdateFailureData hufd;
3133 HTSU_Result res;
3134 HeapTupleData locktup;
3135 HeapTupleTableSlot *hslot = (HeapTupleTableSlot *)outslot;
3136
3137 /* Only a heap tuple has item pointers. */
3138 Assert(TTS_IS_HEAPTUPLE(outslot) || TTS_IS_BUFFERTUPLE(outslot));
3139 ItemPointerCopy(&hslot->tuple->t_self, &locktup.t_self);
3140
3141 PushActiveSnapshot(GetLatestSnapshot());
3142
3143 res = heap_lock_tuple(rel, &locktup, GetCurrentCommandId(false),
3144 lockmode,
3145 LockWaitBlock,
3146 false /* don't follow updates */ ,
3147 &buf, &hufd);
3148 /* the tuple slot already has the buffer pinned */
3149 ReleaseBuffer(buf);
3150
3151 PopActiveSnapshot();
3152
3153 switch (res)
3154 {
3155 case HeapTupleMayBeUpdated:
3156 break;
3157 case HeapTupleUpdated:
3158 /* XXX: Improve handling here */
3159 if (ItemPointerIndicatesMovedPartitions(&hufd.ctid))
3160 ereport(LOG,
3161 (errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
3162 errmsg("tuple to be locked was already moved to another partition due to concurrent update, retrying")));
3163 else
3164 ereport(LOG,
3165 (errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
3166 errmsg("concurrent update, retrying")));
3167 goto retry;
3168 case HeapTupleInvisible:
3169 elog(ERROR, "attempted to lock invisible tuple");
3170 break;
3171 default:
3172 elog(ERROR, "unexpected heap_lock_tuple status: %u", res);
3173 break;
3174 }
3175 }
3176=====================================================================
3177Found a 44 line (243 tokens) duplication in the following files:
3178Starting at line 259 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-describe.c
3179Starting at line 388 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-describe.c
3180
3181 for (i = 1; i <= count1; i++)
3182 {
3183 { ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
3184 ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
3185
3186#line 115 "describe.pgc"
3187
3188if (sqlca.sqlcode < 0) exit (1);}
3189#line 115 "describe.pgc"
3190
3191 { ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
3192 ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
3193
3194#line 116 "describe.pgc"
3195
3196if (sqlca.sqlcode < 0) exit (1);}
3197#line 116 "describe.pgc"
3198
3199 printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
3200 "sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n",
3201 i, field_name1, field_name2,
3202 sqlda1->sqlvar[i-1].sqlname.data,
3203 sqlda2->sqlvar[i-1].sqlname.data,
3204 sqlda3->sqlvar[i-1].sqlname.data);
3205 }
3206
3207 strcpy(msg, "deallocate");
3208 ECPGdeallocate_desc(__LINE__, "desc1");
3209#line 126 "describe.pgc"
3210
3211if (sqlca.sqlcode < 0) exit (1);
3212#line 126 "describe.pgc"
3213
3214 ECPGdeallocate_desc(__LINE__, "desc2");
3215#line 127 "describe.pgc"
3216
3217if (sqlca.sqlcode < 0) exit (1);
3218#line 127 "describe.pgc"
3219
3220 free(sqlda1);
3221 free(sqlda2);
3222 free(sqlda3);
3223
3224 { ECPGdeallocate(__LINE__, 0, NULL, "st_id1");
3225=====================================================================
3226Found a 61 line (241 tokens) duplication in the following files:
3227Starting at line 186 of /home/shackle/pggit/postgresql/src/backend/utils/adt/varbit.c
3228Starting at line 498 of /home/shackle/pggit/postgresql/src/backend/utils/adt/varbit.c
3229
3230 VARBITLEN(result) = atttypmod;
3231
3232 r = VARBITS(result);
3233 if (bit_not_hex)
3234 {
3235 /* Parse the bit representation of the string */
3236 /* We know it fits, as bitlen was compared to atttypmod */
3237 x = HIGHBIT;
3238 for (; *sp; sp++)
3239 {
3240 if (*sp == '1')
3241 *r |= x;
3242 else if (*sp != '0')
3243 ereport(ERROR,
3244 (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
3245 errmsg("\"%c\" is not a valid binary digit",
3246 *sp)));
3247
3248 x >>= 1;
3249 if (x == 0)
3250 {
3251 x = HIGHBIT;
3252 r++;
3253 }
3254 }
3255 }
3256 else
3257 {
3258 /* Parse the hex representation of the string */
3259 for (bc = 0; *sp; sp++)
3260 {
3261 if (*sp >= '0' && *sp <= '9')
3262 x = (bits8) (*sp - '0');
3263 else if (*sp >= 'A' && *sp <= 'F')
3264 x = (bits8) (*sp - 'A') + 10;
3265 else if (*sp >= 'a' && *sp <= 'f')
3266 x = (bits8) (*sp - 'a') + 10;
3267 else
3268 ereport(ERROR,
3269 (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
3270 errmsg("\"%c\" is not a valid hexadecimal digit",
3271 *sp)));
3272
3273 if (bc)
3274 {
3275 *r++ |= x;
3276 bc = 0;
3277 }
3278 else
3279 {
3280 *r = x << 4;
3281 bc = 1;
3282 }
3283 }
3284 }
3285
3286 PG_RETURN_VARBIT_P(result);
3287}
3288
3289
3290Datum
3291=====================================================================
3292Found a 44 line (237 tokens) duplication in the following files:
3293Starting at line 261 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/compat_informix-describe.c
3294Starting at line 390 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/compat_informix-describe.c
3295
3296 for (i = 1; i <= count1; i++)
3297 {
3298 { ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
3299 ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
3300
3301#line 115 "describe.pgc"
3302
3303if (sqlca.sqlcode < 0) exit (1);}
3304#line 115 "describe.pgc"
3305
3306 { ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
3307 ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
3308
3309#line 116 "describe.pgc"
3310
3311if (sqlca.sqlcode < 0) exit (1);}
3312#line 116 "describe.pgc"
3313
3314 printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
3315 "sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n",
3316 i, field_name1, field_name2,
3317 sqlda1->sqlvar[i-1].sqlname,
3318 sqlda2->sqlvar[i-1].sqlname,
3319 sqlda3->sqlvar[i-1].sqlname);
3320 }
3321
3322 strcpy(msg, "deallocate");
3323 ECPGdeallocate_desc(__LINE__, "desc1");
3324#line 126 "describe.pgc"
3325
3326if (sqlca.sqlcode < 0) exit (1);
3327#line 126 "describe.pgc"
3328
3329 ECPGdeallocate_desc(__LINE__, "desc2");
3330#line 127 "describe.pgc"
3331
3332if (sqlca.sqlcode < 0) exit (1);
3333#line 127 "describe.pgc"
3334
3335 free(sqlda1);
3336 free(sqlda2);
3337 free(sqlda3);
3338
3339 { ECPGdeallocate(__LINE__, 1, NULL, "st_id1");
3340=====================================================================
3341Found a 59 line (237 tokens) duplication in the following files:
3342Starting at line 7295 of /home/shackle/pggit/postgresql/src/backend/utils/adt/selfuncs.c
3343Starting at line 7356 of /home/shackle/pggit/postgresql/src/backend/utils/adt/selfuncs.c
3344
3345gistcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
3346 Cost *indexStartupCost, Cost *indexTotalCost,
3347 Selectivity *indexSelectivity, double *indexCorrelation,
3348 double *indexPages)
3349{
3350 IndexOptInfo *index = path->indexinfo;
3351 List *qinfos;
3352 GenericCosts costs;
3353 Cost descentCost;
3354
3355 /* Do preliminary analysis of indexquals */
3356 qinfos = deconstruct_indexquals(path);
3357
3358 MemSet(&costs, 0, sizeof(costs));
3359
3360 genericcostestimate(root, path, loop_count, qinfos, &costs);
3361
3362 /*
3363 * We model index descent costs similarly to those for btree, but to do
3364 * that we first need an idea of the tree height. We somewhat arbitrarily
3365 * assume that the fanout is 100, meaning the tree height is at most
3366 * log100(index->pages).
3367 *
3368 * Although this computation isn't really expensive enough to require
3369 * caching, we might as well use index->tree_height to cache it.
3370 */
3371 if (index->tree_height < 0) /* unknown? */
3372 {
3373 if (index->pages > 1) /* avoid computing log(0) */
3374 index->tree_height = (int) (log(index->pages) / log(100.0));
3375 else
3376 index->tree_height = 0;
3377 }
3378
3379 /*
3380 * Add a CPU-cost component to represent the costs of initial descent. We
3381 * just use log(N) here not log2(N) since the branching factor isn't
3382 * necessarily two anyway. As for btree, charge once per SA scan.
3383 */
3384 if (index->tuples > 1) /* avoid computing log(0) */
3385 {
3386 descentCost = ceil(log(index->tuples)) * cpu_operator_cost;
3387 costs.indexStartupCost += descentCost;
3388 costs.indexTotalCost += costs.num_sa_scans * descentCost;
3389 }
3390
3391 /*
3392 * Likewise add a per-page charge, calculated the same as for btrees.
3393 */
3394 descentCost = (index->tree_height + 1) * 50.0 * cpu_operator_cost;
3395 costs.indexStartupCost += descentCost;
3396 costs.indexTotalCost += costs.num_sa_scans * descentCost;
3397
3398 *indexStartupCost = costs.indexStartupCost;
3399 *indexTotalCost = costs.indexTotalCost;
3400 *indexSelectivity = costs.indexSelectivity;
3401 *indexCorrelation = costs.indexCorrelation;
3402 *indexPages = costs.numIndexPages;
3403}
3404=====================================================================
3405Found a 15 line (234 tokens) duplication in the following files:
3406Starting at line 121 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/compat_informix-rnull.c
3407Starting at line 159 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/compat_informix-rnull.c
3408Starting at line 194 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/compat_informix-rnull.c
3409Starting at line 234 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/compat_informix-rnull.c
3410
3411 { ECPGdo(__LINE__, 1, 0, NULL, 0, ECPGst_normal, "insert into test ( id , c , s , i , b , f , l , dbl ) values ( 1 , $1 , $2 , $3 , $4 , $5 , $6 , $7 )",
3412 ECPGt_char,(c),(long)sizeof("abc"),(long)1,(sizeof("abc"))*sizeof(char),
3413 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
3414 ECPGt_short,&(s),(long)1,(long)1,sizeof(short),
3415 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
3416 ECPGt_int,&(i),(long)1,(long)1,sizeof(int),
3417 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
3418 ECPGt_bool,&(b),(long)1,(long)1,sizeof(bool),
3419 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
3420 ECPGt_float,&(f),(long)1,(long)1,sizeof(float),
3421 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
3422 ECPGt_long,&(l),(long)1,(long)1,sizeof(long),
3423 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
3424 ECPGt_double,&(dbl),(long)1,(long)1,sizeof(double),
3425 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
3426=====================================================================
3427Found a 38 line (231 tokens) duplication in the following files:
3428Starting at line 3847 of /home/shackle/pggit/postgresql/src/backend/utils/adt/timestamp.c
3429Starting at line 3982 of /home/shackle/pggit/postgresql/src/backend/utils/adt/timestamp.c
3430
3431 fsec = 0;
3432 break;
3433 }
3434 case DTK_MILLENNIUM:
3435 /* see comments in timestamptz_trunc */
3436 if (tm->tm_year > 0)
3437 tm->tm_year = ((tm->tm_year + 999) / 1000) * 1000 - 999;
3438 else
3439 tm->tm_year = -((999 - (tm->tm_year - 1)) / 1000) * 1000 + 1;
3440 /* FALL THRU */
3441 case DTK_CENTURY:
3442 /* see comments in timestamptz_trunc */
3443 if (tm->tm_year > 0)
3444 tm->tm_year = ((tm->tm_year + 99) / 100) * 100 - 99;
3445 else
3446 tm->tm_year = -((99 - (tm->tm_year - 1)) / 100) * 100 + 1;
3447 /* FALL THRU */
3448 case DTK_DECADE:
3449 /* see comments in timestamptz_trunc */
3450 if (val != DTK_MILLENNIUM && val != DTK_CENTURY)
3451 {
3452 if (tm->tm_year > 0)
3453 tm->tm_year = (tm->tm_year / 10) * 10;
3454 else
3455 tm->tm_year = -((8 - (tm->tm_year - 1)) / 10) * 10;
3456 }
3457 /* FALL THRU */
3458 case DTK_YEAR:
3459 tm->tm_mon = 1;
3460 /* FALL THRU */
3461 case DTK_QUARTER:
3462 tm->tm_mon = (3 * ((tm->tm_mon - 1) / 3)) + 1;
3463 /* FALL THRU */
3464 case DTK_MONTH:
3465 tm->tm_mday = 1;
3466 /* FALL THRU */
3467 case DTK_DAY:
3468 tm->tm_hour = 0;
3469=====================================================================
3470Found a 64 line (228 tokens) duplication in the following files:
3471Starting at line 2584 of /home/shackle/pggit/postgresql/src/backend/utils/adt/float.c
3472Starting at line 2660 of /home/shackle/pggit/postgresql/src/backend/utils/adt/float.c
3473
3474 transvalues = check_float8_array(transarray, "float8_accum", 3);
3475 N = transvalues[0];
3476 Sx = transvalues[1];
3477 Sxx = transvalues[2];
3478
3479 /*
3480 * Use the Youngs-Cramer algorithm to incorporate the new value into the
3481 * transition values.
3482 */
3483 N += 1.0;
3484 Sx += newval;
3485 if (transvalues[0] > 0.0)
3486 {
3487 tmp = newval * N - Sx;
3488 Sxx += tmp * tmp / (N * transvalues[0]);
3489
3490 /*
3491 * Overflow check. We only report an overflow error when finite
3492 * inputs lead to infinite results. Note also that Sxx should be NaN
3493 * if any of the inputs are infinite, so we intentionally prevent Sxx
3494 * from becoming infinite.
3495 */
3496 if (isinf(Sx) || isinf(Sxx))
3497 {
3498 if (!isinf(transvalues[1]) && !isinf(newval))
3499 ereport(ERROR,
3500 (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
3501 errmsg("value out of range: overflow")));
3502
3503 Sxx = get_float8_nan();
3504 }
3505 }
3506
3507 /*
3508 * If we're invoked as an aggregate, we can cheat and modify our first
3509 * parameter in-place to reduce palloc overhead. Otherwise we construct a
3510 * new array with the updated transition data and return it.
3511 */
3512 if (AggCheckCallContext(fcinfo, NULL))
3513 {
3514 transvalues[0] = N;
3515 transvalues[1] = Sx;
3516 transvalues[2] = Sxx;
3517
3518 PG_RETURN_ARRAYTYPE_P(transarray);
3519 }
3520 else
3521 {
3522 Datum transdatums[3];
3523 ArrayType *result;
3524
3525 transdatums[0] = Float8GetDatumFast(N);
3526 transdatums[1] = Float8GetDatumFast(Sx);
3527 transdatums[2] = Float8GetDatumFast(Sxx);
3528
3529 result = construct_array(transdatums, 3,
3530 FLOAT8OID,
3531 sizeof(float8), FLOAT8PASSBYVAL, 'd');
3532
3533 PG_RETURN_ARRAYTYPE_P(result);
3534 }
3535}
3536
3537Datum
3538=====================================================================
3539Found a 42 line (228 tokens) duplication in the following files:
3540Starting at line 1538 of /home/shackle/pggit/postgresql/src/backend/utils/adt/jsonb.c
3541Starting at line 1762 of /home/shackle/pggit/postgresql/src/backend/utils/adt/jsonb.c
3542
3543 it = JsonbIteratorInit(&jbelem->root);
3544
3545 while ((type = JsonbIteratorNext(&it, &v, false)) != WJB_DONE)
3546 {
3547 switch (type)
3548 {
3549 case WJB_BEGIN_ARRAY:
3550 if (v.val.array.rawScalar)
3551 single_scalar = true;
3552 else
3553 result->res = pushJsonbValue(&result->parseState,
3554 type, NULL);
3555 break;
3556 case WJB_END_ARRAY:
3557 if (!single_scalar)
3558 result->res = pushJsonbValue(&result->parseState,
3559 type, NULL);
3560 break;
3561 case WJB_BEGIN_OBJECT:
3562 case WJB_END_OBJECT:
3563 result->res = pushJsonbValue(&result->parseState,
3564 type, NULL);
3565 break;
3566 case WJB_ELEM:
3567 case WJB_KEY:
3568 case WJB_VALUE:
3569 if (v.type == jbvString)
3570 {
3571 /* copy string values in the aggregate context */
3572 char *buf = palloc(v.val.string.len + 1);
3573
3574 snprintf(buf, v.val.string.len + 1, "%s", v.val.string.val);
3575 v.val.string.val = buf;
3576 }
3577 else if (v.type == jbvNumeric)
3578 {
3579 /* same for numeric */
3580 v.val.numeric =
3581 DatumGetNumeric(DirectFunctionCall1(numeric_uplus,
3582 NumericGetDatum(v.val.numeric)));
3583 }
3584 result->res = pushJsonbValue(&result->parseState,
3585=====================================================================
3586Found a 77 line (228 tokens) duplication in the following files:
3587Starting at line 291 of /home/shackle/pggit/postgresql/src/backend/access/common/indextuple.c
3588Starting at line 494 of /home/shackle/pggit/postgresql/src/backend/access/common/heaptuple.c
3589
3590 if (IndexTupleHasVarwidths(tup))
3591 {
3592 int j;
3593
3594 for (j = 0; j <= attnum; j++)
3595 {
3596 if (TupleDescAttr(tupleDesc, j)->attlen <= 0)
3597 {
3598 slow = true;
3599 break;
3600 }
3601 }
3602 }
3603 }
3604
3605 if (!slow)
3606 {
3607 int natts = tupleDesc->natts;
3608 int j = 1;
3609
3610 /*
3611 * If we get here, we have a tuple with no nulls or var-widths up to
3612 * and including the target attribute, so we can use the cached offset
3613 * ... only we don't have it yet, or we'd not have got here. Since
3614 * it's cheap to compute offsets for fixed-width columns, we take the
3615 * opportunity to initialize the cached offsets for *all* the leading
3616 * fixed-width columns, in hope of avoiding future visits to this
3617 * routine.
3618 */
3619 TupleDescAttr(tupleDesc, 0)->attcacheoff = 0;
3620
3621 /* we might have set some offsets in the slow path previously */
3622 while (j < natts && TupleDescAttr(tupleDesc, j)->attcacheoff > 0)
3623 j++;
3624
3625 off = TupleDescAttr(tupleDesc, j - 1)->attcacheoff +
3626 TupleDescAttr(tupleDesc, j - 1)->attlen;
3627
3628 for (; j < natts; j++)
3629 {
3630 Form_pg_attribute att = TupleDescAttr(tupleDesc, j);
3631
3632 if (att->attlen <= 0)
3633 break;
3634
3635 off = att_align_nominal(off, att->attalign);
3636
3637 att->attcacheoff = off;
3638
3639 off += att->attlen;
3640 }
3641
3642 Assert(j > attnum);
3643
3644 off = TupleDescAttr(tupleDesc, attnum)->attcacheoff;
3645 }
3646 else
3647 {
3648 bool usecache = true;
3649 int i;
3650
3651 /*
3652 * Now we know that we have to walk the tuple CAREFULLY. But we still
3653 * might be able to cache some offsets for next time.
3654 *
3655 * Note - This loop is a little tricky. For each non-null attribute,
3656 * we have to first account for alignment padding before the attr,
3657 * then advance over the attr based on its length. Nulls have no
3658 * storage and no alignment padding either. We can use/set
3659 * attcacheoff until we reach either a null or a var-width attribute.
3660 */
3661 off = 0;
3662 for (i = 0;; i++) /* loop exit is at "break" */
3663 {
3664 Form_pg_attribute att = TupleDescAttr(tupleDesc, i);
3665
3666 if (IndexTupleHasNulls(tup) && att_isnull(i, bp))
3667=====================================================================
3668Found a 60 line (226 tokens) duplication in the following files:
3669Starting at line 711 of /home/shackle/pggit/postgresql/src/bin/pgbench/pgbench.c
3670Starting at line 54 of /home/shackle/pggit/postgresql/src/backend/utils/adt/int8.c
3671
3672strtoint64(const char *str, bool errorOK, int64 *result)
3673{
3674 const char *ptr = str;
3675 int64 tmp = 0;
3676 bool neg = false;
3677
3678 /*
3679 * Do our own scan, rather than relying on sscanf which might be broken
3680 * for long long.
3681 *
3682 * As INT64_MIN can't be stored as a positive 64 bit integer, accumulate
3683 * value as a negative number.
3684 */
3685
3686 /* skip leading spaces */
3687 while (*ptr && isspace((unsigned char) *ptr))
3688 ptr++;
3689
3690 /* handle sign */
3691 if (*ptr == '-')
3692 {
3693 ptr++;
3694 neg = true;
3695 }
3696 else if (*ptr == '+')
3697 ptr++;
3698
3699 /* require at least one digit */
3700 if (unlikely(!isdigit((unsigned char) *ptr)))
3701 goto invalid_syntax;
3702
3703 /* process digits */
3704 while (*ptr && isdigit((unsigned char) *ptr))
3705 {
3706 int8 digit = (*ptr++ - '0');
3707
3708 if (unlikely(pg_mul_s64_overflow(tmp, 10, &tmp)) ||
3709 unlikely(pg_sub_s64_overflow(tmp, digit, &tmp)))
3710 goto out_of_range;
3711 }
3712
3713 /* allow trailing whitespace, but not other trailing chars */
3714 while (*ptr != '\0' && isspace((unsigned char) *ptr))
3715 ptr++;
3716
3717 if (unlikely(*ptr != '\0'))
3718 goto invalid_syntax;
3719
3720 if (!neg)
3721 {
3722 if (unlikely(tmp == PG_INT64_MIN))
3723 goto out_of_range;
3724 tmp = -tmp;
3725 }
3726
3727 *result = tmp;
3728 return true;
3729
3730out_of_range:
3731 if (!errorOK)
3732=====================================================================
3733Found a 54 line (223 tokens) duplication in the following files:
3734Starting at line 1882 of /home/shackle/pggit/postgresql/src/backend/commands/extension.c
3735Starting at line 1991 of /home/shackle/pggit/postgresql/src/backend/commands/extension.c
3736
3737pg_available_extensions(PG_FUNCTION_ARGS)
3738{
3739 ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo;
3740 TupleDesc tupdesc;
3741 Tuplestorestate *tupstore;
3742 MemoryContext per_query_ctx;
3743 MemoryContext oldcontext;
3744 char *location;
3745 DIR *dir;
3746 struct dirent *de;
3747
3748 /* check to see if caller supports us returning a tuplestore */
3749 if (rsinfo == NULL || !IsA(rsinfo, ReturnSetInfo))
3750 ereport(ERROR,
3751 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3752 errmsg("set-valued function called in context that cannot accept a set")));
3753 if (!(rsinfo->allowedModes & SFRM_Materialize))
3754 ereport(ERROR,
3755 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3756 errmsg("materialize mode required, but it is not " \
3757 "allowed in this context")));
3758
3759 /* Build a tuple descriptor for our result type */
3760 if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
3761 elog(ERROR, "return type must be a row type");
3762
3763 /* Build tuplestore to hold the result rows */
3764 per_query_ctx = rsinfo->econtext->ecxt_per_query_memory;
3765 oldcontext = MemoryContextSwitchTo(per_query_ctx);
3766
3767 tupstore = tuplestore_begin_heap(true, false, work_mem);
3768 rsinfo->returnMode = SFRM_Materialize;
3769 rsinfo->setResult = tupstore;
3770 rsinfo->setDesc = tupdesc;
3771
3772 MemoryContextSwitchTo(oldcontext);
3773
3774 location = get_extension_control_directory();
3775 dir = AllocateDir(location);
3776
3777 /*
3778 * If the control directory doesn't exist, we want to silently return an
3779 * empty set. Any other error will be reported by ReadDir.
3780 */
3781 if (dir == NULL && errno == ENOENT)
3782 {
3783 /* do nothing */
3784 }
3785 else
3786 {
3787 while ((de = ReadDir(dir, location)) != NULL)
3788 {
3789 ExtensionControlFile *control;
3790 char *extname;
3791=====================================================================
3792Found a 42 line (215 tokens) duplication in the following files:
3793Starting at line 4600 of /home/shackle/pggit/postgresql/src/backend/utils/adt/timestamp.c
3794Starting at line 4811 of /home/shackle/pggit/postgresql/src/backend/utils/adt/timestamp.c
3795
3796 if (tm->tm_year >= 0)
3797 result = tm->tm_year / 10;
3798 else
3799 result = -((8 - (tm->tm_year - 1)) / 10);
3800 break;
3801
3802 case DTK_CENTURY:
3803
3804 /* ----
3805 * centuries AD, c>0: year in [ (c-1)* 100 + 1 : c*100 ]
3806 * centuries BC, c<0: year in [ c*100 : (c+1) * 100 - 1]
3807 * there is no number 0 century.
3808 * ----
3809 */
3810 if (tm->tm_year > 0)
3811 result = (tm->tm_year + 99) / 100;
3812 else
3813 /* caution: C division may have negative remainder */
3814 result = -((99 - (tm->tm_year - 1)) / 100);
3815 break;
3816
3817 case DTK_MILLENNIUM:
3818 /* see comments above. */
3819 if (tm->tm_year > 0)
3820 result = (tm->tm_year + 999) / 1000;
3821 else
3822 result = -((999 - (tm->tm_year - 1)) / 1000);
3823 break;
3824
3825 case DTK_JULIAN:
3826 result = date2j(tm->tm_year, tm->tm_mon, tm->tm_mday);
3827 result += ((((tm->tm_hour * MINS_PER_HOUR) + tm->tm_min) * SECS_PER_MINUTE) +
3828 tm->tm_sec + (fsec / 1000000.0)) / (double) SECS_PER_DAY;
3829 break;
3830
3831 case DTK_ISOYEAR:
3832 result = date2isoyear(tm->tm_year, tm->tm_mon, tm->tm_mday);
3833 break;
3834
3835 case DTK_DOW:
3836 case DTK_ISODOW:
3837 if (timestamp2tm(timestamp, NULL, tm, &fsec, NULL, NULL) != 0)
3838=====================================================================
3839Found a 55 line (213 tokens) duplication in the following files:
3840Starting at line 88 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
3841Starting at line 466 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
3842
3843 StringInfoData buf;
3844
3845 check_stack_depth(); /* recurses for record-type columns */
3846
3847 /*
3848 * Give a friendly error message if we did not get enough info to identify
3849 * the target record type. (lookup_rowtype_tupdesc would fail anyway, but
3850 * with a non-user-friendly message.) In ordinary SQL usage, we'll get -1
3851 * for typmod, since composite types and RECORD have no type modifiers at
3852 * the SQL level, and thus must fail for RECORD. However some callers can
3853 * supply a valid typmod, and then we can do something useful for RECORD.
3854 */
3855 if (tupType == RECORDOID && tupTypmod < 0)
3856 ereport(ERROR,
3857 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3858 errmsg("input of anonymous composite types is not implemented")));
3859
3860 /*
3861 * This comes from the composite type's pg_type.oid and stores system oids
3862 * in user tables, specifically DatumTupleFields. This oid must be
3863 * preserved by binary upgrades.
3864 */
3865 tupdesc = lookup_rowtype_tupdesc(tupType, tupTypmod);
3866 ncolumns = tupdesc->natts;
3867
3868 /*
3869 * We arrange to look up the needed I/O info just once per series of
3870 * calls, assuming the record type doesn't change underneath us.
3871 */
3872 my_extra = (RecordIOData *) fcinfo->flinfo->fn_extra;
3873 if (my_extra == NULL ||
3874 my_extra->ncolumns != ncolumns)
3875 {
3876 fcinfo->flinfo->fn_extra =
3877 MemoryContextAlloc(fcinfo->flinfo->fn_mcxt,
3878 offsetof(RecordIOData, columns) +
3879 ncolumns * sizeof(ColumnIOData));
3880 my_extra = (RecordIOData *) fcinfo->flinfo->fn_extra;
3881 my_extra->record_type = InvalidOid;
3882 my_extra->record_typmod = 0;
3883 }
3884
3885 if (my_extra->record_type != tupType ||
3886 my_extra->record_typmod != tupTypmod)
3887 {
3888 MemSet(my_extra, 0,
3889 offsetof(RecordIOData, columns) +
3890 ncolumns * sizeof(ColumnIOData));
3891 my_extra->record_type = tupType;
3892 my_extra->record_typmod = tupTypmod;
3893 my_extra->ncolumns = ncolumns;
3894 }
3895
3896 values = (Datum *) palloc(ncolumns * sizeof(Datum));
3897 nulls = (bool *) palloc(ncolumns * sizeof(bool));
3898=====================================================================
3899Found a 23 line (212 tokens) duplication in the following files:
3900Starting at line 152 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-oldexec.c
3901Starting at line 151 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-execute.c
3902
3903 { ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "fetch 8 in CUR", ECPGt_EOIT,
3904 ECPGt_char,(name),(long)8,(long)8,(8)*sizeof(char),
3905 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
3906 ECPGt_int,(amount),(long)1,(long)8,sizeof(int),
3907 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
3908 ECPGt_char,(letter),(long)1,(long)8,(1)*sizeof(char),
3909 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
3910#line 54 "oldexec.pgc"
3911
3912if (sqlca.sqlcode < 0) sqlprint();}
3913#line 54 "oldexec.pgc"
3914
3915
3916 for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
3917 {
3918 char n[8], l = letter[i][0];
3919 int a = amount[i];
3920
3921 strncpy(n, name[i], 8);
3922 printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l);
3923 }
3924
3925 { ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "close CUR", ECPGt_EOIT, ECPGt_EORT);
3926=====================================================================
3927Found a 23 line (212 tokens) duplication in the following files:
3928Starting at line 152 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-oldexec.c
3929Starting at line 203 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-oldexec.c
3930
3931 { ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "fetch 8 in CUR", ECPGt_EOIT,
3932 ECPGt_char,(name),(long)8,(long)8,(8)*sizeof(char),
3933 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
3934 ECPGt_int,(amount),(long)1,(long)8,sizeof(int),
3935 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
3936 ECPGt_char,(letter),(long)1,(long)8,(1)*sizeof(char),
3937 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
3938#line 54 "oldexec.pgc"
3939
3940if (sqlca.sqlcode < 0) sqlprint();}
3941#line 54 "oldexec.pgc"
3942
3943
3944 for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
3945 {
3946 char n[8], l = letter[i][0];
3947 int a = amount[i];
3948
3949 strncpy(n, name[i], 8);
3950 printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l);
3951 }
3952
3953 { ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "close CUR", ECPGt_EOIT, ECPGt_EORT);
3954=====================================================================
3955Found a 33 line (212 tokens) duplication in the following files:
3956Starting at line 151 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-execute.c
3957Starting at line 218 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-execute.c
3958
3959 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 8 in CUR", ECPGt_EOIT,
3960 ECPGt_char,(name),(long)8,(long)8,(8)*sizeof(char),
3961 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
3962 ECPGt_int,(amount),(long)1,(long)8,sizeof(int),
3963 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
3964 ECPGt_char,(letter),(long)1,(long)8,(1)*sizeof(char),
3965 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
3966#line 53 "execute.pgc"
3967
3968if (sqlca.sqlcode < 0) sqlprint();}
3969#line 53 "execute.pgc"
3970
3971
3972 for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
3973 {
3974 /* exec sql begin declare section */
3975
3976
3977
3978#line 58 "execute.pgc"
3979 char n [ 8 ] , l = letter [ i ] [ 0 ] ;
3980
3981#line 59 "execute.pgc"
3982 int a = amount [ i ] ;
3983/* exec sql end declare section */
3984#line 60 "execute.pgc"
3985
3986
3987 strncpy(n, name[i], 8);
3988 printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l);
3989 }
3990
3991 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close CUR", ECPGt_EOIT, ECPGt_EORT);
3992=====================================================================
3993Found a 51 line (212 tokens) duplication in the following files:
3994Starting at line 36 of /home/shackle/pggit/postgresql/src/backend/access/rmgrdesc/xactdesc.c
3995Starting at line 131 of /home/shackle/pggit/postgresql/src/backend/access/rmgrdesc/xactdesc.c
3996
3997 char *data = ((char *) xlrec) + MinSizeOfXactCommit;
3998
3999 memset(parsed, 0, sizeof(*parsed));
4000
4001 parsed->xinfo = 0; /* default, if no XLOG_XACT_HAS_INFO is
4002 * present */
4003
4004 parsed->xact_time = xlrec->xact_time;
4005
4006 if (info & XLOG_XACT_HAS_INFO)
4007 {
4008 xl_xact_xinfo *xl_xinfo = (xl_xact_xinfo *) data;
4009
4010 parsed->xinfo = xl_xinfo->xinfo;
4011
4012 data += sizeof(xl_xact_xinfo);
4013 }
4014
4015 if (parsed->xinfo & XACT_XINFO_HAS_DBINFO)
4016 {
4017 xl_xact_dbinfo *xl_dbinfo = (xl_xact_dbinfo *) data;
4018
4019 parsed->dbId = xl_dbinfo->dbId;
4020 parsed->tsId = xl_dbinfo->tsId;
4021
4022 data += sizeof(xl_xact_dbinfo);
4023 }
4024
4025 if (parsed->xinfo & XACT_XINFO_HAS_SUBXACTS)
4026 {
4027 xl_xact_subxacts *xl_subxacts = (xl_xact_subxacts *) data;
4028
4029 parsed->nsubxacts = xl_subxacts->nsubxacts;
4030 parsed->subxacts = xl_subxacts->subxacts;
4031
4032 data += MinSizeOfXactSubxacts;
4033 data += parsed->nsubxacts * sizeof(TransactionId);
4034 }
4035
4036 if (parsed->xinfo & XACT_XINFO_HAS_RELFILENODES)
4037 {
4038 xl_xact_relfilenodes *xl_relfilenodes = (xl_xact_relfilenodes *) data;
4039
4040 parsed->nrels = xl_relfilenodes->nrels;
4041 parsed->xnodes = xl_relfilenodes->xnodes;
4042
4043 data += MinSizeOfXactRelfilenodes;
4044 data += xl_relfilenodes->nrels * sizeof(RelFileNode);
4045 }
4046
4047 if (parsed->xinfo & XACT_XINFO_HAS_INVALS)
4048=====================================================================
4049Found a 56 line (212 tokens) duplication in the following files:
4050Starting at line 513 of /home/shackle/pggit/postgresql/src/backend/access/hash/hash_xlog.c
4051Starting at line 641 of /home/shackle/pggit/postgresql/src/backend/access/hash/hash_xlog.c
4052
4053 Buffer deletebuf = InvalidBuffer;
4054 XLogRedoAction action;
4055
4056 /*
4057 * Ensure we have a cleanup lock on primary bucket page before we start
4058 * with the actual replay operation. This is to ensure that neither a
4059 * scan can start nor a scan can be already-in-progress during the replay
4060 * of this operation. If we allow scans during this operation, then they
4061 * can miss some records or show the same record multiple times.
4062 */
4063 if (xldata->is_prim_bucket_same_wrt)
4064 action = XLogReadBufferForRedoExtended(record, 1, RBM_NORMAL, true, &writebuf);
4065 else
4066 {
4067 /*
4068 * we don't care for return value as the purpose of reading bucketbuf
4069 * is to ensure a cleanup lock on primary bucket page.
4070 */
4071 (void) XLogReadBufferForRedoExtended(record, 0, RBM_NORMAL, true, &bucketbuf);
4072
4073 action = XLogReadBufferForRedo(record, 1, &writebuf);
4074 }
4075
4076 /* replay the record for adding entries in overflow buffer */
4077 if (action == BLK_NEEDS_REDO)
4078 {
4079 Page writepage;
4080 char *begin;
4081 char *data;
4082 Size datalen;
4083 uint16 ninserted = 0;
4084
4085 data = begin = XLogRecGetBlockData(record, 1, &datalen);
4086
4087 writepage = (Page) BufferGetPage(writebuf);
4088
4089 if (xldata->ntups > 0)
4090 {
4091 OffsetNumber *towrite = (OffsetNumber *) data;
4092
4093 data += sizeof(OffsetNumber) * xldata->ntups;
4094
4095 while (data - begin < datalen)
4096 {
4097 IndexTuple itup = (IndexTuple) data;
4098 Size itemsz;
4099 OffsetNumber l;
4100
4101 itemsz = IndexTupleSize(itup);
4102 itemsz = MAXALIGN(itemsz);
4103
4104 data += itemsz;
4105
4106 l = PageAddItem(writepage, (Item) itup, itemsz, towrite[ninserted], false, false);
4107 if (l == InvalidOffsetNumber)
4108 elog(ERROR, "hash_xlog_move_page_contents: failed to add item to hash index page, size %d bytes",
4109=====================================================================
4110Found a 28 line (211 tokens) duplication in the following files:
4111Starting at line 641 of /home/shackle/pggit/postgresql/src/backend/regex/regc_lex.c
4112Starting at line 997 of /home/shackle/pggit/postgresql/src/backend/regex/regc_lex.c
4113
4114 RETV(')', c);
4115 break;
4116 case CHR('['): /* easy except for [[:<:]] and [[:>:]] */
4117 if (HAVE(6) && *(v->now + 0) == CHR('[') &&
4118 *(v->now + 1) == CHR(':') &&
4119 (*(v->now + 2) == CHR('<') ||
4120 *(v->now + 2) == CHR('>')) &&
4121 *(v->now + 3) == CHR(':') &&
4122 *(v->now + 4) == CHR(']') &&
4123 *(v->now + 5) == CHR(']'))
4124 {
4125 c = *(v->now + 2);
4126 v->now += 6;
4127 NOTE(REG_UNONPOSIX);
4128 RET((c == CHR('<')) ? '<' : '>');
4129 }
4130 INTOCON(L_BRACK);
4131 if (NEXT1('^'))
4132 {
4133 v->now++;
4134 RETV('[', 0);
4135 }
4136 RETV('[', 1);
4137 break;
4138 case CHR('.'):
4139 RET('.');
4140 break;
4141 case CHR('^'):
4142=====================================================================
4143Found a 23 line (208 tokens) duplication in the following files:
4144Starting at line 152 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-oldexec.c
4145Starting at line 218 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-execute.c
4146
4147 { ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "fetch 8 in CUR", ECPGt_EOIT,
4148 ECPGt_char,(name),(long)8,(long)8,(8)*sizeof(char),
4149 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
4150 ECPGt_int,(amount),(long)1,(long)8,sizeof(int),
4151 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
4152 ECPGt_char,(letter),(long)1,(long)8,(1)*sizeof(char),
4153 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
4154#line 54 "oldexec.pgc"
4155
4156if (sqlca.sqlcode < 0) sqlprint();}
4157#line 54 "oldexec.pgc"
4158
4159
4160 for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
4161 {
4162 char n[8], l = letter[i][0];
4163 int a = amount[i];
4164
4165 strncpy(n, name[i], 8);
4166 printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l);
4167 }
4168
4169 { ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "close CUR", ECPGt_EOIT, ECPGt_EORT);
4170=====================================================================
4171Found a 23 line (208 tokens) duplication in the following files:
4172Starting at line 203 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-oldexec.c
4173Starting at line 151 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-execute.c
4174
4175 { ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "fetch in CUR3", ECPGt_EOIT,
4176 ECPGt_char,(name),(long)8,(long)8,(8)*sizeof(char),
4177 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
4178 ECPGt_int,(amount),(long)1,(long)8,sizeof(int),
4179 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
4180 ECPGt_char,(letter),(long)1,(long)8,(1)*sizeof(char),
4181 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
4182#line 73 "oldexec.pgc"
4183
4184if (sqlca.sqlcode < 0) sqlprint();}
4185#line 73 "oldexec.pgc"
4186
4187
4188 for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
4189 {
4190 char n[8], l = letter[i][0];
4191 int a = amount[i];
4192
4193 strncpy(n, name[i], 8);
4194 printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l);
4195 }
4196
4197 { ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "close CUR3", ECPGt_EOIT, ECPGt_EORT);
4198=====================================================================
4199Found a 52 line (206 tokens) duplication in the following files:
4200Starting at line 176 of /home/shackle/pggit/postgresql/src/backend/utils/time/tqual.c
4201Starting at line 366 of /home/shackle/pggit/postgresql/src/backend/utils/time/tqual.c
4202
4203HeapTupleSatisfiesSelf(HeapTuple htup, Snapshot snapshot, Buffer buffer)
4204{
4205 HeapTupleHeader tuple = htup->t_data;
4206
4207 Assert(ItemPointerIsValid(&htup->t_self));
4208 Assert(htup->t_tableOid != InvalidOid);
4209
4210 if (!HeapTupleHeaderXminCommitted(tuple))
4211 {
4212 if (HeapTupleHeaderXminInvalid(tuple))
4213 return false;
4214
4215 /* Used by pre-9.0 binary upgrades */
4216 if (tuple->t_infomask & HEAP_MOVED_OFF)
4217 {
4218 TransactionId xvac = HeapTupleHeaderGetXvac(tuple);
4219
4220 if (TransactionIdIsCurrentTransactionId(xvac))
4221 return false;
4222 if (!TransactionIdIsInProgress(xvac))
4223 {
4224 if (TransactionIdDidCommit(xvac))
4225 {
4226 SetHintBits(tuple, buffer, HEAP_XMIN_INVALID,
4227 InvalidTransactionId);
4228 return false;
4229 }
4230 SetHintBits(tuple, buffer, HEAP_XMIN_COMMITTED,
4231 InvalidTransactionId);
4232 }
4233 }
4234 /* Used by pre-9.0 binary upgrades */
4235 else if (tuple->t_infomask & HEAP_MOVED_IN)
4236 {
4237 TransactionId xvac = HeapTupleHeaderGetXvac(tuple);
4238
4239 if (!TransactionIdIsCurrentTransactionId(xvac))
4240 {
4241 if (TransactionIdIsInProgress(xvac))
4242 return false;
4243 if (TransactionIdDidCommit(xvac))
4244 SetHintBits(tuple, buffer, HEAP_XMIN_COMMITTED,
4245 InvalidTransactionId);
4246 else
4247 {
4248 SetHintBits(tuple, buffer, HEAP_XMIN_INVALID,
4249 InvalidTransactionId);
4250 return false;
4251 }
4252 }
4253 }
4254 else if (TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetRawXmin(tuple)))
4255=====================================================================
4256Found a 50 line (205 tokens) duplication in the following files:
4257Starting at line 884 of /home/shackle/pggit/postgresql/src/backend/executor/execTuples.c
4258Starting at line 1277 of /home/shackle/pggit/postgresql/src/backend/access/common/heaptuple.c
4259
4260 for (; attnum < natts; attnum++)
4261 {
4262 Form_pg_attribute thisatt = TupleDescAttr(tupleDesc, attnum);
4263
4264 if (hasnulls && att_isnull(attnum, bp))
4265 {
4266 values[attnum] = (Datum) 0;
4267 isnull[attnum] = true;
4268 slow = true; /* can't use attcacheoff anymore */
4269 continue;
4270 }
4271
4272 isnull[attnum] = false;
4273
4274 if (!slow && thisatt->attcacheoff >= 0)
4275 off = thisatt->attcacheoff;
4276 else if (thisatt->attlen == -1)
4277 {
4278 /*
4279 * We can only cache the offset for a varlena attribute if the
4280 * offset is already suitably aligned, so that there would be no
4281 * pad bytes in any case: then the offset will be valid for either
4282 * an aligned or unaligned value.
4283 */
4284 if (!slow &&
4285 off == att_align_nominal(off, thisatt->attalign))
4286 thisatt->attcacheoff = off;
4287 else
4288 {
4289 off = att_align_pointer(off, thisatt->attalign, -1,
4290 tp + off);
4291 slow = true;
4292 }
4293 }
4294 else
4295 {
4296 /* not varlena, so safe to use att_align_nominal */
4297 off = att_align_nominal(off, thisatt->attalign);
4298
4299 if (!slow)
4300 thisatt->attcacheoff = off;
4301 }
4302
4303 values[attnum] = fetchatt(thisatt, tp + off);
4304
4305 off = att_addlength_pointer(off, thisatt->attlen, tp + off);
4306
4307 if (thisatt->attlen <= 0)
4308 slow = true; /* can't use attcacheoff anymore */
4309 }
4310=====================================================================
4311Found a 66 line (204 tokens) duplication in the following files:
4312Starting at line 197 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-secure-openssl.c
4313Starting at line 306 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-secure-openssl.c
4314
4315 goto rloop;
4316 case SSL_ERROR_SYSCALL:
4317 if (n < 0)
4318 {
4319 result_errno = SOCK_ERRNO;
4320 if (result_errno == EPIPE ||
4321 result_errno == ECONNRESET)
4322 printfPQExpBuffer(&conn->errorMessage,
4323 libpq_gettext(
4324 "server closed the connection unexpectedly\n"
4325 "\tThis probably means the server terminated abnormally\n"
4326 "\tbefore or while processing the request.\n"));
4327 else
4328 printfPQExpBuffer(&conn->errorMessage,
4329 libpq_gettext("SSL SYSCALL error: %s\n"),
4330 SOCK_STRERROR(result_errno,
4331 sebuf, sizeof(sebuf)));
4332 }
4333 else
4334 {
4335 printfPQExpBuffer(&conn->errorMessage,
4336 libpq_gettext("SSL SYSCALL error: EOF detected\n"));
4337 /* assume the connection is broken */
4338 result_errno = ECONNRESET;
4339 n = -1;
4340 }
4341 break;
4342 case SSL_ERROR_SSL:
4343 {
4344 char *errm = SSLerrmessage(ecode);
4345
4346 printfPQExpBuffer(&conn->errorMessage,
4347 libpq_gettext("SSL error: %s\n"), errm);
4348 SSLerrfree(errm);
4349 /* assume the connection is broken */
4350 result_errno = ECONNRESET;
4351 n = -1;
4352 break;
4353 }
4354 case SSL_ERROR_ZERO_RETURN:
4355
4356 /*
4357 * Per OpenSSL documentation, this error code is only returned for
4358 * a clean connection closure, so we should not report it as a
4359 * server crash.
4360 */
4361 printfPQExpBuffer(&conn->errorMessage,
4362 libpq_gettext("SSL connection has been closed unexpectedly\n"));
4363 result_errno = ECONNRESET;
4364 n = -1;
4365 break;
4366 default:
4367 printfPQExpBuffer(&conn->errorMessage,
4368 libpq_gettext("unrecognized SSL error code: %d\n"),
4369 err);
4370 /* assume the connection is broken */
4371 result_errno = ECONNRESET;
4372 n = -1;
4373 break;
4374 }
4375
4376 /* ensure we return the intended errno to caller */
4377 SOCK_ERRNO_SET(result_errno);
4378
4379 return n;
4380}
4381=====================================================================
4382Found a 29 line (204 tokens) duplication in the following files:
4383Starting at line 1498 of /home/shackle/pggit/postgresql/src/backend/utils/error/elog.c
4384Starting at line 1678 of /home/shackle/pggit/postgresql/src/backend/utils/error/elog.c
4385
4386 newedata = (ErrorData *) palloc(sizeof(ErrorData));
4387 memcpy(newedata, edata, sizeof(ErrorData));
4388
4389 /* Make copies of separately-allocated fields */
4390 if (newedata->message)
4391 newedata->message = pstrdup(newedata->message);
4392 if (newedata->detail)
4393 newedata->detail = pstrdup(newedata->detail);
4394 if (newedata->detail_log)
4395 newedata->detail_log = pstrdup(newedata->detail_log);
4396 if (newedata->hint)
4397 newedata->hint = pstrdup(newedata->hint);
4398 if (newedata->context)
4399 newedata->context = pstrdup(newedata->context);
4400 if (newedata->schema_name)
4401 newedata->schema_name = pstrdup(newedata->schema_name);
4402 if (newedata->table_name)
4403 newedata->table_name = pstrdup(newedata->table_name);
4404 if (newedata->column_name)
4405 newedata->column_name = pstrdup(newedata->column_name);
4406 if (newedata->datatype_name)
4407 newedata->datatype_name = pstrdup(newedata->datatype_name);
4408 if (newedata->constraint_name)
4409 newedata->constraint_name = pstrdup(newedata->constraint_name);
4410 if (newedata->internalquery)
4411 newedata->internalquery = pstrdup(newedata->internalquery);
4412
4413 /* Use the calling context for string allocation */
4414 newedata->assoc_context = CurrentMemoryContext;
4415=====================================================================
4416Found a 68 line (203 tokens) duplication in the following files:
4417Starting at line 160 of /home/shackle/pggit/postgresql/src/test/examples/testlo64.c
4418Starting at line 139 of /home/shackle/pggit/postgresql/src/test/examples/testlo.c
4419
4420 fprintf(stderr, "error in lo_truncate64: %s", PQerrorMessage(conn));
4421
4422 lo_close(conn, lobj_fd);
4423}
4424
4425
4426/*
4427 * exportFile -
4428 * export large object "lobjOid" to file "out_filename"
4429 *
4430 */
4431static void
4432exportFile(PGconn *conn, Oid lobjId, char *filename)
4433{
4434 int lobj_fd;
4435 char buf[BUFSIZE];
4436 int nbytes,
4437 tmp;
4438 int fd;
4439
4440 /*
4441 * open the large object
4442 */
4443 lobj_fd = lo_open(conn, lobjId, INV_READ);
4444 if (lobj_fd < 0)
4445 fprintf(stderr, "cannot open large object %u", lobjId);
4446
4447 /*
4448 * open the file to be written to
4449 */
4450 fd = open(filename, O_CREAT | O_WRONLY | O_TRUNC, 0666);
4451 if (fd < 0)
4452 { /* error */
4453 fprintf(stderr, "cannot open unix file\"%s\"",
4454 filename);
4455 }
4456
4457 /*
4458 * read in from the inversion file and write to the Unix file
4459 */
4460 while ((nbytes = lo_read(conn, lobj_fd, buf, BUFSIZE)) > 0)
4461 {
4462 tmp = write(fd, buf, nbytes);
4463 if (tmp < nbytes)
4464 {
4465 fprintf(stderr, "error while writing \"%s\"",
4466 filename);
4467 }
4468 }
4469
4470 lo_close(conn, lobj_fd);
4471 close(fd);
4472
4473 return;
4474}
4475
4476static void
4477exit_nicely(PGconn *conn)
4478{
4479 PQfinish(conn);
4480 exit(1);
4481}
4482
4483int
4484main(int argc, char **argv)
4485{
4486 char *in_filename,
4487 *out_filename,
4488=====================================================================
4489Found a 33 line (203 tokens) duplication in the following files:
4490Starting at line 77 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.c
4491Starting at line 135 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.c
4492
4493 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into nantest1 ( id , d ) values ( 1 , 'nan' :: float8 ) , ( 2 , 'infinity' :: float8 ) , ( 3 , '-infinity' :: float8 )", ECPGt_EOIT, ECPGt_EORT);
4494#line 33 "nan_test.pgc"
4495
4496if (sqlca.sqlcode < 0) sqlprint ( );}
4497#line 33 "nan_test.pgc"
4498
4499
4500 /* declare cur cursor for select id , d , d from nantest1 */
4501#line 35 "nan_test.pgc"
4502
4503 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur cursor for select id , d , d from nantest1", ECPGt_EOIT, ECPGt_EORT);
4504#line 36 "nan_test.pgc"
4505
4506if (sqlca.sqlcode < 0) sqlprint ( );}
4507#line 36 "nan_test.pgc"
4508
4509 while (1)
4510 {
4511 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch from cur", ECPGt_EOIT,
4512 ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
4513 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
4514 ECPGt_double,&(d),(long)1,(long)1,sizeof(double),
4515 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
4516 ECPGt_char,(val),(long)16,(long)1,(16)*sizeof(char),
4517 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
4518#line 39 "nan_test.pgc"
4519
4520if (sqlca.sqlcode < 0) sqlprint ( );}
4521#line 39 "nan_test.pgc"
4522
4523 if (sqlca.sqlcode)
4524 break;
4525 if (isnan(d))
4526=====================================================================
4527Found a 36 line (202 tokens) duplication in the following files:
4528Starting at line 336 of /home/shackle/pggit/postgresql/src/backend/access/brin/brin_minmax.c
4529Starting at line 668 of /home/shackle/pggit/postgresql/src/backend/access/brin/brin_inclusion.c
4530
4531 for (i = 1; i <= BTMaxStrategyNumber; i++)
4532 opaque->strategy_procinfos[i - 1].fn_oid = InvalidOid;
4533 opaque->cached_subtype = subtype;
4534 }
4535
4536 if (opaque->strategy_procinfos[strategynum - 1].fn_oid == InvalidOid)
4537 {
4538 Form_pg_attribute attr;
4539 HeapTuple tuple;
4540 Oid opfamily,
4541 oprid;
4542 bool isNull;
4543
4544 opfamily = bdesc->bd_index->rd_opfamily[attno - 1];
4545 attr = TupleDescAttr(bdesc->bd_tupdesc, attno - 1);
4546 tuple = SearchSysCache4(AMOPSTRATEGY, ObjectIdGetDatum(opfamily),
4547 ObjectIdGetDatum(attr->atttypid),
4548 ObjectIdGetDatum(subtype),
4549 Int16GetDatum(strategynum));
4550
4551 if (!HeapTupleIsValid(tuple))
4552 elog(ERROR, "missing operator %d(%u,%u) in opfamily %u",
4553 strategynum, attr->atttypid, subtype, opfamily);
4554
4555 oprid = DatumGetObjectId(SysCacheGetAttr(AMOPSTRATEGY, tuple,
4556 Anum_pg_amop_amopopr, &isNull));
4557 ReleaseSysCache(tuple);
4558 Assert(!isNull && RegProcedureIsValid(oprid));
4559
4560 fmgr_info_cxt(get_opcode(oprid),
4561 &opaque->strategy_procinfos[strategynum - 1],
4562 bdesc->bd_context);
4563 }
4564
4565 return &opaque->strategy_procinfos[strategynum - 1];
4566}
4567=====================================================================
4568Found a 39 line (200 tokens) duplication in the following files:
4569Starting at line 1174 of /home/shackle/pggit/postgresql/src/backend/jit/llvm/llvmjit_expr.c
4570Starting at line 1859 of /home/shackle/pggit/postgresql/src/backend/jit/llvm/llvmjit_expr.c
4571
4572 case EEOP_CASE_TESTVAL:
4573 {
4574 LLVMBasicBlockRef b_avail,
4575 b_notavail;
4576 LLVMValueRef v_casevaluep,
4577 v_casevalue;
4578 LLVMValueRef v_casenullp,
4579 v_casenull;
4580 LLVMValueRef v_casevaluenull;
4581
4582 b_avail = l_bb_before_v(opblocks[i + 1],
4583 "op.%d.avail", i);
4584 b_notavail = l_bb_before_v(opblocks[i + 1],
4585 "op.%d.notavail", i);
4586
4587 v_casevaluep = l_ptr_const(op->d.casetest.value,
4588 l_ptr(TypeSizeT));
4589 v_casenullp = l_ptr_const(op->d.casetest.isnull,
4590 l_ptr(TypeStorageBool));
4591
4592 v_casevaluenull =
4593 LLVMBuildICmp(b, LLVMIntEQ,
4594 LLVMBuildPtrToInt(b, v_casevaluep,
4595 TypeSizeT, ""),
4596 l_sizet_const(0), "");
4597 LLVMBuildCondBr(b, v_casevaluenull, b_notavail, b_avail);
4598
4599 /* if casetest != NULL */
4600 LLVMPositionBuilderAtEnd(b, b_avail);
4601 v_casevalue = LLVMBuildLoad(b, v_casevaluep, "");
4602 v_casenull = LLVMBuildLoad(b, v_casenullp, "");
4603 LLVMBuildStore(b, v_casevalue, v_resvaluep);
4604 LLVMBuildStore(b, v_casenull, v_resnullp);
4605 LLVMBuildBr(b, opblocks[i + 1]);
4606
4607 /* if casetest == NULL */
4608 LLVMPositionBuilderAtEnd(b, b_notavail);
4609 v_casevalue =
4610 l_load_struct_gep(b, v_econtext,
4611=====================================================================
4612Found a 36 line (198 tokens) duplication in the following files:
4613Starting at line 123 of /home/shackle/pggit/postgresql/contrib/pgcrypto/crypt-gensalt.c
4614Starting at line 403 of /home/shackle/pggit/postgresql/contrib/pgcrypto/crypt-blowfish.c
4615
4616static void
4617BF_encode(char *dst, const BF_word *src, int size)
4618{
4619 const unsigned char *sptr = (const unsigned char *) src;
4620 const unsigned char *end = sptr + size;
4621 unsigned char *dptr = (unsigned char *) dst;
4622 unsigned int c1,
4623 c2;
4624
4625 do
4626 {
4627 c1 = *sptr++;
4628 *dptr++ = BF_itoa64[c1 >> 2];
4629 c1 = (c1 & 0x03) << 4;
4630 if (sptr >= end)
4631 {
4632 *dptr++ = BF_itoa64[c1];
4633 break;
4634 }
4635
4636 c2 = *sptr++;
4637 c1 |= c2 >> 4;
4638 *dptr++ = BF_itoa64[c1];
4639 c1 = (c2 & 0x0f) << 2;
4640 if (sptr >= end)
4641 {
4642 *dptr++ = BF_itoa64[c1];
4643 break;
4644 }
4645
4646 c2 = *sptr++;
4647 c1 |= c2 >> 6;
4648 *dptr++ = BF_itoa64[c1];
4649 *dptr++ = BF_itoa64[c2 & 0x3f];
4650 } while (sptr < end);
4651}
4652=====================================================================
4653Found a 23 line (198 tokens) duplication in the following files:
4654Starting at line 152 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-oldexec.c
4655Starting at line 203 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-oldexec.c
4656Starting at line 151 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-execute.c
4657Starting at line 218 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-execute.c
4658Starting at line 273 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-execute.c
4659
4660 { ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "fetch 8 in CUR", ECPGt_EOIT,
4661 ECPGt_char,(name),(long)8,(long)8,(8)*sizeof(char),
4662 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
4663 ECPGt_int,(amount),(long)1,(long)8,sizeof(int),
4664 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
4665 ECPGt_char,(letter),(long)1,(long)8,(1)*sizeof(char),
4666 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
4667#line 54 "oldexec.pgc"
4668
4669if (sqlca.sqlcode < 0) sqlprint();}
4670#line 54 "oldexec.pgc"
4671
4672
4673 for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
4674 {
4675 char n[8], l = letter[i][0];
4676 int a = amount[i];
4677
4678 strncpy(n, name[i], 8);
4679 printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l);
4680 }
4681
4682 { ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "close CUR", ECPGt_EOIT, ECPGt_EORT);
4683=====================================================================
4684Found a 30 line (196 tokens) duplication in the following files:
4685Starting at line 52 of /home/shackle/pggit/postgresql/src/fe_utils/mbprint.c
4686Starting at line 713 of /home/shackle/pggit/postgresql/src/backend/utils/mb/wchar.c
4687
4688static pg_wchar
4689utf8_to_unicode(const unsigned char *c)
4690{
4691 if ((*c & 0x80) == 0)
4692 return (pg_wchar) c[0];
4693 else if ((*c & 0xe0) == 0xc0)
4694 return (pg_wchar) (((c[0] & 0x1f) << 6) |
4695 (c[1] & 0x3f));
4696 else if ((*c & 0xf0) == 0xe0)
4697 return (pg_wchar) (((c[0] & 0x0f) << 12) |
4698 ((c[1] & 0x3f) << 6) |
4699 (c[2] & 0x3f));
4700 else if ((*c & 0xf8) == 0xf0)
4701 return (pg_wchar) (((c[0] & 0x07) << 18) |
4702 ((c[1] & 0x3f) << 12) |
4703 ((c[2] & 0x3f) << 6) |
4704 (c[3] & 0x3f));
4705 else
4706 /* that is an invalid code on purpose */
4707 return 0xffffffff;
4708}
4709
4710
4711/*
4712 * Unicode 3.1 compliant validation : for each category, it checks the
4713 * combination of each byte to make sure it maps to a valid range. It also
4714 * returns -1 for the following UCS values: ucs > 0x10ffff ucs & 0xfffe =
4715 * 0xfffe 0xfdd0 < ucs < 0xfdef ucs & 0xdb00 = 0xd800 (surrogates)
4716 */
4717static int
4718=====================================================================
4719Found a 13 line (196 tokens) duplication in the following files:
4720Starting at line 239 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-array.c
4721Starting at line 294 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-array.c
4722
4723 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
4724 ECPGt_short,(a),(long)1,(long)10,sizeof(short),
4725 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
4726 ECPGt_char,&(t),(long)0,(long)1,(1)*sizeof(char),
4727 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
4728 ECPGt_timestamp,&(ts),(long)1,(long)10,sizeof(timestamp),
4729 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
4730 ECPGt_numeric,&(n),(long)1,(long)10,sizeof(numeric),
4731 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
4732 ECPGt_date,&(d),(long)1,(long)10,sizeof(date),
4733 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
4734 ECPGt_interval,&(in),(long)1,(long)10,sizeof(interval),
4735 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
4736=====================================================================
4737Found a 48 line (194 tokens) duplication in the following files:
4738Starting at line 142 of /home/shackle/pggit/postgresql/src/backend/utils/adt/oracle_compat.c
4739Starting at line 240 of /home/shackle/pggit/postgresql/src/backend/utils/adt/oracle_compat.c
4740
4741lpad(PG_FUNCTION_ARGS)
4742{
4743 text *string1 = PG_GETARG_TEXT_PP(0);
4744 int32 len = PG_GETARG_INT32(1);
4745 text *string2 = PG_GETARG_TEXT_PP(2);
4746 text *ret;
4747 char *ptr1,
4748 *ptr2,
4749 *ptr2start,
4750 *ptr2end,
4751 *ptr_ret;
4752 int m,
4753 s1len,
4754 s2len;
4755
4756 int bytelen;
4757
4758 /* Negative len is silently taken as zero */
4759 if (len < 0)
4760 len = 0;
4761
4762 s1len = VARSIZE_ANY_EXHDR(string1);
4763 if (s1len < 0)
4764 s1len = 0; /* shouldn't happen */
4765
4766 s2len = VARSIZE_ANY_EXHDR(string2);
4767 if (s2len < 0)
4768 s2len = 0; /* shouldn't happen */
4769
4770 s1len = pg_mbstrlen_with_len(VARDATA_ANY(string1), s1len);
4771
4772 if (s1len > len)
4773 s1len = len; /* truncate string1 to len chars */
4774
4775 if (s2len <= 0)
4776 len = s1len; /* nothing to pad with, so don't pad */
4777
4778 bytelen = pg_database_encoding_max_length() * len;
4779
4780 /* check for integer overflow */
4781 if (len != 0 && bytelen / pg_database_encoding_max_length() != len)
4782 ereport(ERROR,
4783 (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
4784 errmsg("requested length too large")));
4785
4786 ret = (text *) palloc(VARHDRSZ + bytelen);
4787
4788 m = len - s1len;
4789=====================================================================
4790Found a 29 line (193 tokens) duplication in the following files:
4791Starting at line 1577 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_dumpall.c
4792Starting at line 94 of /home/shackle/pggit/postgresql/src/bin/pg_basebackup/streamutil.c
4793
4794 exit_nicely(1);
4795 }
4796
4797 for (conn_opt = conn_opts; conn_opt->keyword != NULL; conn_opt++)
4798 {
4799 if (conn_opt->val != NULL && conn_opt->val[0] != '\0' &&
4800 strcmp(conn_opt->keyword, "dbname") != 0)
4801 argcount++;
4802 }
4803
4804 keywords = pg_malloc0((argcount + 1) * sizeof(*keywords));
4805 values = pg_malloc0((argcount + 1) * sizeof(*values));
4806
4807 for (conn_opt = conn_opts; conn_opt->keyword != NULL; conn_opt++)
4808 {
4809 if (conn_opt->val != NULL && conn_opt->val[0] != '\0' &&
4810 strcmp(conn_opt->keyword, "dbname") != 0)
4811 {
4812 keywords[i] = conn_opt->keyword;
4813 values[i] = conn_opt->val;
4814 i++;
4815 }
4816 }
4817 }
4818 else
4819 {
4820 keywords = pg_malloc0((argcount + 1) * sizeof(*keywords));
4821 values = pg_malloc0((argcount + 1) * sizeof(*values));
4822 }
4823=====================================================================
4824Found a 26 line (193 tokens) duplication in the following files:
4825Starting at line 1346 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
4826Starting at line 1665 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
4827
4828 InitFunctionCallInfoData(fcinfo, flinfo, 9, collation, NULL, NULL);
4829
4830 fcinfo.arg[0] = arg1;
4831 fcinfo.arg[1] = arg2;
4832 fcinfo.arg[2] = arg3;
4833 fcinfo.arg[3] = arg4;
4834 fcinfo.arg[4] = arg5;
4835 fcinfo.arg[5] = arg6;
4836 fcinfo.arg[6] = arg7;
4837 fcinfo.arg[7] = arg8;
4838 fcinfo.arg[8] = arg9;
4839 fcinfo.argnull[0] = false;
4840 fcinfo.argnull[1] = false;
4841 fcinfo.argnull[2] = false;
4842 fcinfo.argnull[3] = false;
4843 fcinfo.argnull[4] = false;
4844 fcinfo.argnull[5] = false;
4845 fcinfo.argnull[6] = false;
4846 fcinfo.argnull[7] = false;
4847 fcinfo.argnull[8] = false;
4848
4849 result = FunctionCallInvoke(&fcinfo);
4850
4851 /* Check for null result, since caller is clearly not expecting one */
4852 if (fcinfo.isnull)
4853 elog(ERROR, "function %u returned NULL", fcinfo.flinfo->fn_oid);
4854=====================================================================
4855Found a 18 line (192 tokens) duplication in the following files:
4856Starting at line 864 of /home/shackle/pggit/postgresql/contrib/pg_trgm/trgm_gist.c
4857Starting at line 711 of /home/shackle/pggit/postgresql/src/backend/utils/adt/tsgistidx.c
4858
4859 datum_r = (TRGM *) palloc(CALCGTSIZE(SIGNKEY, 0));
4860 SET_VARSIZE(datum_r, CALCGTSIZE(SIGNKEY, 0));
4861 datum_r->flag = SIGNKEY;
4862 memcpy((void *) GETSIGN(datum_r), (void *) cache[seed_2].sign, sizeof(BITVEC));
4863 }
4864
4865 union_l = GETSIGN(datum_l);
4866 union_r = GETSIGN(datum_r);
4867 maxoff = OffsetNumberNext(maxoff);
4868 fillcache(&cache[maxoff], GETENTRY(entryvec, maxoff));
4869 /* sort before ... */
4870 costvector = (SPLITCOST *) palloc(sizeof(SPLITCOST) * maxoff);
4871 for (j = FirstOffsetNumber; j <= maxoff; j = OffsetNumberNext(j))
4872 {
4873 costvector[j - 1].pos = j;
4874 size_alpha = hemdistcache(&(cache[seed_1]), &(cache[j]));
4875 size_beta = hemdistcache(&(cache[seed_2]), &(cache[j]));
4876 costvector[j - 1].cost = abs(size_alpha - size_beta);
4877=====================================================================
4878Found a 63 line (192 tokens) duplication in the following files:
4879Starting at line 114 of /home/shackle/pggit/postgresql/src/backend/utils/adt/varbit.c
4880Starting at line 430 of /home/shackle/pggit/postgresql/src/backend/utils/adt/varbit.c
4881
4882bit_in(PG_FUNCTION_ARGS)
4883{
4884 char *input_string = PG_GETARG_CSTRING(0);
4885
4886#ifdef NOT_USED
4887 Oid typelem = PG_GETARG_OID(1);
4888#endif
4889 int32 atttypmod = PG_GETARG_INT32(2);
4890 VarBit *result; /* The resulting bit string */
4891 char *sp; /* pointer into the character string */
4892 bits8 *r; /* pointer into the result */
4893 int len, /* Length of the whole data structure */
4894 bitlen, /* Number of bits in the bit string */
4895 slen; /* Length of the input string */
4896 bool bit_not_hex; /* false = hex string true = bit string */
4897 int bc;
4898 bits8 x = 0;
4899
4900 /* Check that the first character is a b or an x */
4901 if (input_string[0] == 'b' || input_string[0] == 'B')
4902 {
4903 bit_not_hex = true;
4904 sp = input_string + 1;
4905 }
4906 else if (input_string[0] == 'x' || input_string[0] == 'X')
4907 {
4908 bit_not_hex = false;
4909 sp = input_string + 1;
4910 }
4911 else
4912 {
4913 /*
4914 * Otherwise it's binary. This allows things like cast('1001' as bit)
4915 * to work transparently.
4916 */
4917 bit_not_hex = true;
4918 sp = input_string;
4919 }
4920
4921 /*
4922 * Determine bitlength from input string. MaxAllocSize ensures a regular
4923 * input is small enough, but we must check hex input.
4924 */
4925 slen = strlen(sp);
4926 if (bit_not_hex)
4927 bitlen = slen;
4928 else
4929 {
4930 if (slen > VARBITMAXLEN / 4)
4931 ereport(ERROR,
4932 (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
4933 errmsg("bit string length exceeds the maximum allowed (%d)",
4934 VARBITMAXLEN)));
4935 bitlen = slen * 4;
4936 }
4937
4938 /*
4939 * Sometimes atttypmod is not supplied. If it is supplied we need to make
4940 * sure that the bitstring fits.
4941 */
4942 if (atttypmod <= 0)
4943 atttypmod = bitlen;
4944 else if (bitlen != atttypmod)
4945=====================================================================
4946Found a 37 line (191 tokens) duplication in the following files:
4947Starting at line 54 of /home/shackle/pggit/postgresql/src/backend/access/brin/brin_validate.c
4948Starting at line 54 of /home/shackle/pggit/postgresql/src/backend/access/nbtree/nbtvalidate.c
4949
4950 OpFamilyOpFuncGroup *opclassgroup;
4951 int i;
4952 ListCell *lc;
4953
4954 /* Fetch opclass information */
4955 classtup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclassoid));
4956 if (!HeapTupleIsValid(classtup))
4957 elog(ERROR, "cache lookup failed for operator class %u", opclassoid);
4958 classform = (Form_pg_opclass) GETSTRUCT(classtup);
4959
4960 opfamilyoid = classform->opcfamily;
4961 opcintype = classform->opcintype;
4962 opclassname = NameStr(classform->opcname);
4963
4964 /* Fetch opfamily information */
4965 familytup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfamilyoid));
4966 if (!HeapTupleIsValid(familytup))
4967 elog(ERROR, "cache lookup failed for operator family %u", opfamilyoid);
4968 familyform = (Form_pg_opfamily) GETSTRUCT(familytup);
4969
4970 opfamilyname = NameStr(familyform->opfname);
4971
4972 /* Fetch all operators and support functions of the opfamily */
4973 oprlist = SearchSysCacheList1(AMOPSTRATEGY, ObjectIdGetDatum(opfamilyoid));
4974 proclist = SearchSysCacheList1(AMPROCNUM, ObjectIdGetDatum(opfamilyoid));
4975
4976 /* Check individual support functions */
4977 for (i = 0; i < proclist->n_members; i++)
4978 {
4979 HeapTuple proctup = &proclist->members[i]->tuple;
4980 Form_pg_amproc procform = (Form_pg_amproc) GETSTRUCT(proctup);
4981 bool ok;
4982
4983 /* Check procedure numbers and function signatures */
4984 switch (procform->amprocnum)
4985 {
4986 case BRIN_PROCNUM_OPCINFO:
4987=====================================================================
4988Found a 42 line (190 tokens) duplication in the following files:
4989Starting at line 584 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/dt_common.c
4990Starting at line 274 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
4991
4992int
4993date2j(int y, int m, int d)
4994{
4995 int julian;
4996 int century;
4997
4998 if (m > 2)
4999 {
5000 m += 1;
5001 y += 4800;
5002 }
5003 else
5004 {
5005 m += 13;
5006 y += 4799;
5007 }
5008
5009 century = y / 100;
5010 julian = y * 365 - 32167;
5011 julian += y / 4 - century + century / 4;
5012 julian += 7834 * m / 256 + d;
5013
5014 return julian;
5015} /* date2j() */
5016
5017void
5018j2date(int jd, int *year, int *month, int *day)
5019{
5020 unsigned int julian;
5021 unsigned int quad;
5022 unsigned int extra;
5023 int y;
5024
5025 julian = jd;
5026 julian += 32044;
5027 quad = julian / 146097;
5028 extra = (julian - quad * 146097) * 4 + 3;
5029 julian += 60 + quad * 3 + extra / 146097;
5030 quad = julian / 1461;
5031 julian -= quad * 1461;
5032 y = julian * 4 / 1461;
5033 julian = ((y != 0) ? (julian + 305) % 365 : (julian + 306) % 366) + 123;
5034=====================================================================
5035Found a 42 line (190 tokens) duplication in the following files:
5036Starting at line 814 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/dt_common.c
5037Starting at line 860 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/dt_common.c
5038
5039 sprintf(str + 5, "/%04d %02d:%02d",
5040 (tm->tm_year > 0) ? tm->tm_year : -(tm->tm_year - 1),
5041 tm->tm_hour, tm->tm_min);
5042
5043 /*
5044 * Print fractional seconds if any. The field widths here should
5045 * be at least equal to MAX_TIMESTAMP_PRECISION.
5046 */
5047 if (fsec != 0)
5048 {
5049 sprintf(str + strlen(str), ":%02d.%06d", tm->tm_sec, fsec);
5050 TrimTrailingZeros(str);
5051 }
5052 else
5053 sprintf(str + strlen(str), ":%02d", tm->tm_sec);
5054
5055 if (tm->tm_year <= 0)
5056 sprintf(str + strlen(str), " BC");
5057
5058 /*
5059 * Note: the uses of %.*s in this function would be risky if the
5060 * timezone names ever contain non-ASCII characters. However, all
5061 * TZ abbreviations in the IANA database are plain ASCII.
5062 */
5063
5064 if (print_tz)
5065 {
5066 if (tzn)
5067 sprintf(str + strlen(str), " %.*s", MAXTZLEN, tzn);
5068 else
5069 {
5070 hour = -(tz / SECS_PER_HOUR);
5071 min = (abs(tz) / MINS_PER_HOUR) % MINS_PER_HOUR;
5072 if (min != 0)
5073 sprintf(str + strlen(str), "%+03d:%02d", hour, min);
5074 else
5075 sprintf(str + strlen(str), "%+03d", hour);
5076 }
5077 }
5078 break;
5079
5080 case USE_GERMAN_DATES:
5081=====================================================================
5082Found a 19 line (190 tokens) duplication in the following files:
5083Starting at line 231 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
5084Starting at line 371 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
5085Starting at line 539 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
5086
5087 ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
5088 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
5089 ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
5090 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
5091 ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
5092 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
5093#line 78 "cursor.pgc"
5094
5095if (sqlca.sqlcode < 0) exit (1);}
5096#line 78 "cursor.pgc"
5097
5098 printf("%d %s\n", id, t);
5099
5100 strcpy(msg, "fetch :count from");
5101 count = 1;
5102 { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 from $0",
5103 ECPGt_int,&(count),(long)1,(long)1,sizeof(int),
5104 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
5105 ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
5106=====================================================================
5107Found a 19 line (190 tokens) duplication in the following files:
5108Starting at line 274 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
5109Starting at line 418 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
5110Starting at line 582 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
5111
5112 ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
5113 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
5114 ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
5115 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
5116 ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
5117 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
5118#line 90 "cursor.pgc"
5119
5120if (sqlca.sqlcode < 0) exit (1);}
5121#line 90 "cursor.pgc"
5122
5123 printf("%d %s\n", id, t);
5124
5125 strcpy(msg, "fetch :count");
5126 count = 1;
5127 { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 $0",
5128 ECPGt_int,&(count),(long)1,(long)1,sizeof(int),
5129 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
5130 ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
5131=====================================================================
5132Found a 64 line (189 tokens) duplication in the following files:
5133Starting at line 9493 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_dump.c
5134Starting at line 14954 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_dump.c
5135
5136 high = &comments[ncomments - 1];
5137 while (low <= high)
5138 {
5139 middle = low + (high - low) / 2;
5140
5141 if (classoid < middle->classoid)
5142 high = middle - 1;
5143 else if (classoid > middle->classoid)
5144 low = middle + 1;
5145 else if (objoid < middle->objoid)
5146 high = middle - 1;
5147 else if (objoid > middle->objoid)
5148 low = middle + 1;
5149 else
5150 break; /* found a match */
5151 }
5152
5153 if (low > high) /* no matches */
5154 {
5155 *items = NULL;
5156 return 0;
5157 }
5158
5159 /*
5160 * Now determine how many items match the object. The search loop
5161 * invariant still holds: only items between low and high inclusive could
5162 * match.
5163 */
5164 nmatch = 1;
5165 while (middle > low)
5166 {
5167 if (classoid != middle[-1].classoid ||
5168 objoid != middle[-1].objoid)
5169 break;
5170 middle--;
5171 nmatch++;
5172 }
5173
5174 *items = middle;
5175
5176 middle += nmatch;
5177 while (middle <= high)
5178 {
5179 if (classoid != middle->classoid ||
5180 objoid != middle->objoid)
5181 break;
5182 middle++;
5183 nmatch++;
5184 }
5185
5186 return nmatch;
5187}
5188
5189/*
5190 * collectComments --
5191 *
5192 * Construct a table of all comments available for database objects.
5193 * We used to do per-object queries for the comments, but it's much faster
5194 * to pull them all over at once, and on most databases the memory cost
5195 * isn't high.
5196 *
5197 * The table is sorted by classoid/objid/objsubid for speed in lookup.
5198 */
5199static int
5200=====================================================================
5201Found a 59 line (189 tokens) duplication in the following files:
5202Starting at line 1330 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
5203Starting at line 2187 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
5204
5205 return DTERR_BAD_FORMAT;
5206
5207 /***
5208 * We will need one of the following fields:
5209 * DTK_NUMBER should be hhmmss.fff
5210 * DTK_TIME should be hh:mm:ss.fff
5211 * DTK_DATE should be hhmmss-zz
5212 ***/
5213 if (i >= nf - 1 ||
5214 (ftype[i + 1] != DTK_NUMBER &&
5215 ftype[i + 1] != DTK_TIME &&
5216 ftype[i + 1] != DTK_DATE))
5217 return DTERR_BAD_FORMAT;
5218
5219 ptype = val;
5220 break;
5221
5222 case UNKNOWN_FIELD:
5223
5224 /*
5225 * Before giving up and declaring error, check to see
5226 * if it is an all-alpha timezone name.
5227 */
5228 namedTz = pg_tzset(field[i]);
5229 if (!namedTz)
5230 return DTERR_BAD_FORMAT;
5231 /* we'll apply the zone setting below */
5232 tmask = DTK_M(TZ);
5233 break;
5234
5235 default:
5236 return DTERR_BAD_FORMAT;
5237 }
5238 break;
5239
5240 default:
5241 return DTERR_BAD_FORMAT;
5242 }
5243
5244 if (tmask & fmask)
5245 return DTERR_BAD_FORMAT;
5246 fmask |= tmask;
5247 } /* end loop over fields */
5248
5249 /* do final checking/adjustment of Y/M/D fields */
5250 dterr = ValidateDate(fmask, isjulian, is2digits, bc, tm);
5251 if (dterr)
5252 return dterr;
5253
5254 /* handle AM/PM */
5255 if (mer != HR24 && tm->tm_hour > HOURS_PER_DAY / 2)
5256 return DTERR_FIELD_OVERFLOW;
5257 if (mer == AM && tm->tm_hour == HOURS_PER_DAY / 2)
5258 tm->tm_hour = 0;
5259 else if (mer == PM && tm->tm_hour != HOURS_PER_DAY / 2)
5260 tm->tm_hour += HOURS_PER_DAY / 2;
5261
5262 /* do additional checking for full date specs... */
5263 if (*dtype == DTK_DATE)
5264=====================================================================
5265Found a 52 line (189 tokens) duplication in the following files:
5266Starting at line 703 of /home/shackle/pggit/postgresql/src/backend/access/heap/heapam.c
5267Starting at line 993 of /home/shackle/pggit/postgresql/src/backend/access/heap/heapam.c
5268
5269 if (backward)
5270 {
5271 finished = (page == scan->rs_startblock) ||
5272 (scan->rs_numblocks != InvalidBlockNumber ? --scan->rs_numblocks == 0 : false);
5273 if (page == 0)
5274 page = scan->rs_nblocks;
5275 page--;
5276 }
5277 else if (scan->rs_parallel != NULL)
5278 {
5279 page = heap_parallelscan_nextpage(scan);
5280 finished = (page == InvalidBlockNumber);
5281 }
5282 else
5283 {
5284 page++;
5285 if (page >= scan->rs_nblocks)
5286 page = 0;
5287 finished = (page == scan->rs_startblock) ||
5288 (scan->rs_numblocks != InvalidBlockNumber ? --scan->rs_numblocks == 0 : false);
5289
5290 /*
5291 * Report our new scan position for synchronization purposes. We
5292 * don't do that when moving backwards, however. That would just
5293 * mess up any other forward-moving scanners.
5294 *
5295 * Note: we do this before checking for end of scan so that the
5296 * final state of the position hint is back at the start of the
5297 * rel. That's not strictly necessary, but otherwise when you run
5298 * the same query multiple times the starting position would shift
5299 * a little bit backwards on every invocation, which is confusing.
5300 * We don't guarantee any specific ordering in general, though.
5301 */
5302 if (scan->rs_syncscan)
5303 ss_report_location(scan->rs_rd, page);
5304 }
5305
5306 /*
5307 * return NULL if we've exhausted all the pages
5308 */
5309 if (finished)
5310 {
5311 if (BufferIsValid(scan->rs_cbuf))
5312 ReleaseBuffer(scan->rs_cbuf);
5313 scan->rs_cbuf = InvalidBuffer;
5314 scan->rs_cblock = InvalidBlockNumber;
5315 tuple->t_data = NULL;
5316 scan->rs_inited = false;
5317 return;
5318 }
5319
5320 heapgetpage(scan, page);
5321=====================================================================
5322Found a 43 line (188 tokens) duplication in the following files:
5323Starting at line 5584 of /home/shackle/pggit/postgresql/src/backend/utils/adt/formatting.c
5324Starting at line 5694 of /home/shackle/pggit/postgresql/src/backend/utils/adt/formatting.c
5325
5326 if (*orgnum == '-')
5327 {
5328 sign = '-';
5329 orgnum++;
5330 }
5331 else
5332 sign = '+';
5333
5334 numstr_pre_len = strlen(orgnum);
5335
5336 /* post-decimal digits? Pad out with zeros. */
5337 if (Num.post)
5338 {
5339 numstr = (char *) palloc(numstr_pre_len + Num.post + 2);
5340 strcpy(numstr, orgnum);
5341 *(numstr + numstr_pre_len) = '.';
5342 memset(numstr + numstr_pre_len + 1, '0', Num.post);
5343 *(numstr + numstr_pre_len + Num.post + 1) = '\0';
5344 }
5345 else
5346 numstr = orgnum;
5347
5348 /* needs padding? */
5349 if (numstr_pre_len < Num.pre)
5350 out_pre_spaces = Num.pre - numstr_pre_len;
5351 /* overflowed prefix digit format? */
5352 else if (numstr_pre_len > Num.pre)
5353 {
5354 numstr = (char *) palloc(Num.pre + Num.post + 2);
5355 fill_str(numstr, '#', Num.pre + Num.post + 1);
5356 *(numstr + Num.pre) = '.';
5357 }
5358 }
5359
5360 NUM_TOCHAR_finish;
5361 PG_RETURN_TEXT_P(result);
5362}
5363
5364/* ---------------
5365 * INT8 to_char()
5366 * ---------------
5367 */
5368Datum
5369=====================================================================
5370Found a 42 line (188 tokens) duplication in the following files:
5371Starting at line 2170 of /home/shackle/pggit/postgresql/src/backend/commands/analyze.c
5372Starting at line 2535 of /home/shackle/pggit/postgresql/src/backend/commands/analyze.c
5373
5374 if (track_cnt < track_max && toowide_cnt == 0 &&
5375 stats->stadistinct > 0 &&
5376 track_cnt <= num_mcv)
5377 {
5378 /* Track list includes all values seen, and all will fit */
5379 num_mcv = track_cnt;
5380 }
5381 else
5382 {
5383 int *mcv_counts;
5384
5385 /* Incomplete list; decide how many values are worth keeping */
5386 if (num_mcv > track_cnt)
5387 num_mcv = track_cnt;
5388
5389 if (num_mcv > 0)
5390 {
5391 mcv_counts = (int *) palloc(num_mcv * sizeof(int));
5392 for (i = 0; i < num_mcv; i++)
5393 mcv_counts[i] = track[i].count;
5394
5395 num_mcv = analyze_mcv_list(mcv_counts, num_mcv,
5396 stats->stadistinct,
5397 stats->stanullfrac,
5398 samplerows, totalrows);
5399 }
5400 }
5401
5402 /* Generate MCV slot entry */
5403 if (num_mcv > 0)
5404 {
5405 MemoryContext old_context;
5406 Datum *mcv_values;
5407 float4 *mcv_freqs;
5408
5409 /* Must copy the target values into anl_context */
5410 old_context = MemoryContextSwitchTo(stats->anl_context);
5411 mcv_values = (Datum *) palloc(num_mcv * sizeof(Datum));
5412 mcv_freqs = (float4 *) palloc(num_mcv * sizeof(float4));
5413 for (i = 0; i < num_mcv; i++)
5414 {
5415 mcv_values[i] = datumCopy(track[i].value,
5416=====================================================================
5417Found a 15 line (185 tokens) duplication in the following files:
5418Starting at line 1737 of /home/shackle/pggit/postgresql/src/backend/utils/mb/wchar.c
5419Starting at line 1751 of /home/shackle/pggit/postgresql/src/backend/utils/mb/wchar.c
5420
5421 {pg_mule2wchar_with_len, pg_wchar2mule_with_len, pg_mule_mblen, pg_mule_dsplen, pg_mule_verifier, 4}, /* PG_MULE_INTERNAL */
5422 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN1 */
5423 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN2 */
5424 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN3 */
5425 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN4 */
5426 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN5 */
5427 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN6 */
5428 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN7 */
5429 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN8 */
5430 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN9 */
5431 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN10 */
5432 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_WIN1256 */
5433 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_WIN1258 */
5434 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_WIN866 */
5435 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_WIN874 */
5436=====================================================================
5437Found a 34 line (184 tokens) duplication in the following files:
5438Starting at line 698 of /home/shackle/pggit/postgresql/src/backend/utils/adt/array_userfuncs.c
5439Starting at line 837 of /home/shackle/pggit/postgresql/src/backend/utils/adt/array_userfuncs.c
5440
5441 my_extra = (ArrayMetaState *) fcinfo->flinfo->fn_extra;
5442 if (my_extra == NULL)
5443 {
5444 fcinfo->flinfo->fn_extra = MemoryContextAlloc(fcinfo->flinfo->fn_mcxt,
5445 sizeof(ArrayMetaState));
5446 my_extra = (ArrayMetaState *) fcinfo->flinfo->fn_extra;
5447 my_extra->element_type = ~element_type;
5448 }
5449
5450 if (my_extra->element_type != element_type)
5451 {
5452 get_typlenbyvalalign(element_type,
5453 &my_extra->typlen,
5454 &my_extra->typbyval,
5455 &my_extra->typalign);
5456
5457 typentry = lookup_type_cache(element_type, TYPECACHE_EQ_OPR_FINFO);
5458
5459 if (!OidIsValid(typentry->eq_opr_finfo.fn_oid))
5460 ereport(ERROR,
5461 (errcode(ERRCODE_UNDEFINED_FUNCTION),
5462 errmsg("could not identify an equality operator for type %s",
5463 format_type_be(element_type))));
5464
5465 my_extra->element_type = element_type;
5466 fmgr_info_cxt(typentry->eq_opr_finfo.fn_oid, &my_extra->proc,
5467 fcinfo->flinfo->fn_mcxt);
5468 }
5469
5470 /* Examine each array element until we find a match. */
5471 array_iterator = array_create_iterator(array, 0, my_extra);
5472 while (array_iterate(array_iterator, &value, &isnull))
5473 {
5474 position++;
5475=====================================================================
5476Found a 47 line (184 tokens) duplication in the following files:
5477Starting at line 880 of /home/shackle/pggit/postgresql/src/backend/access/brin/brin.c
5478Starting at line 957 of /home/shackle/pggit/postgresql/src/backend/access/brin/brin.c
5479
5480 if (heapBlk64 > BRIN_ALL_BLOCKRANGES || heapBlk64 < 0)
5481 {
5482 char *blk = psprintf(INT64_FORMAT, heapBlk64);
5483
5484 ereport(ERROR,
5485 (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
5486 errmsg("block number out of range: %s", blk)));
5487 }
5488 heapBlk = (BlockNumber) heapBlk64;
5489
5490 /*
5491 * We must lock table before index to avoid deadlocks. However, if the
5492 * passed indexoid isn't an index then IndexGetRelation() will fail.
5493 * Rather than emitting a not-very-helpful error message, postpone
5494 * complaining, expecting that the is-it-an-index test below will fail.
5495 */
5496 heapoid = IndexGetRelation(indexoid, true);
5497 if (OidIsValid(heapoid))
5498 heapRel = heap_open(heapoid, ShareUpdateExclusiveLock);
5499 else
5500 heapRel = NULL;
5501
5502 indexRel = index_open(indexoid, ShareUpdateExclusiveLock);
5503
5504 /* Must be a BRIN index */
5505 if (indexRel->rd_rel->relkind != RELKIND_INDEX ||
5506 indexRel->rd_rel->relam != BRIN_AM_OID)
5507 ereport(ERROR,
5508 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
5509 errmsg("\"%s\" is not a BRIN index",
5510 RelationGetRelationName(indexRel))));
5511
5512 /* User must own the index (comparable to privileges needed for VACUUM) */
5513 if (!pg_class_ownercheck(indexoid, GetUserId()))
5514 aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_INDEX,
5515 RelationGetRelationName(indexRel));
5516
5517 /*
5518 * Since we did the IndexGetRelation call above without any lock, it's
5519 * barely possible that a race against an index drop/recreation could have
5520 * netted us the wrong table. Recheck.
5521 */
5522 if (heapRel == NULL || heapoid != IndexGetRelation(indexoid, false))
5523 ereport(ERROR,
5524 (errcode(ERRCODE_UNDEFINED_TABLE),
5525 errmsg("could not open parent table of index %s",
5526 RelationGetRelationName(indexRel))));
5527=====================================================================
5528Found a 36 line (183 tokens) duplication in the following files:
5529Starting at line 299 of /home/shackle/pggit/postgresql/contrib/ltree/_ltree_gist.c
5530Starting at line 351 of /home/shackle/pggit/postgresql/contrib/intarray/_intbig_gist.c
5531
5532 ltree_gist *_k,
5533 *_j;
5534
5535 maxoff = entryvec->n - 2;
5536 nbytes = (maxoff + 2) * sizeof(OffsetNumber);
5537 v->spl_left = (OffsetNumber *) palloc(nbytes);
5538 v->spl_right = (OffsetNumber *) palloc(nbytes);
5539
5540 for (k = FirstOffsetNumber; k < maxoff; k = OffsetNumberNext(k))
5541 {
5542 _k = GETENTRY(entryvec, k);
5543 for (j = OffsetNumberNext(k); j <= maxoff; j = OffsetNumberNext(j))
5544 {
5545 size_waste = hemdist(_k, GETENTRY(entryvec, j));
5546 if (size_waste > waste)
5547 {
5548 waste = size_waste;
5549 seed_1 = k;
5550 seed_2 = j;
5551 }
5552 }
5553 }
5554
5555 left = v->spl_left;
5556 v->spl_nleft = 0;
5557 right = v->spl_right;
5558 v->spl_nright = 0;
5559
5560 if (seed_1 == 0 || seed_2 == 0)
5561 {
5562 seed_1 = 1;
5563 seed_2 = 2;
5564 }
5565
5566 /* form initial .. */
5567 if (LTG_ISALLTRUE(GETENTRY(entryvec, seed_1)))
5568=====================================================================
5569Found a 36 line (182 tokens) duplication in the following files:
5570Starting at line 59 of /home/shackle/pggit/postgresql/contrib/pgcrypto/pgp-armor.c
5571Starting at line 232 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
5572
5573 buf |= *s << (pos << 3);
5574 pos--;
5575 s++;
5576
5577 /*
5578 * write it out
5579 */
5580 if (pos < 0)
5581 {
5582 *p++ = _base64[(buf >> 18) & 0x3f];
5583 *p++ = _base64[(buf >> 12) & 0x3f];
5584 *p++ = _base64[(buf >> 6) & 0x3f];
5585 *p++ = _base64[buf & 0x3f];
5586
5587 pos = 2;
5588 buf = 0;
5589 }
5590 if (p >= lend)
5591 {
5592 *p++ = '\n';
5593 lend = p + 76;
5594 }
5595 }
5596 if (pos != 2)
5597 {
5598 *p++ = _base64[(buf >> 18) & 0x3f];
5599 *p++ = _base64[(buf >> 12) & 0x3f];
5600 *p++ = (pos == 0) ? _base64[(buf >> 6) & 0x3f] : '=';
5601 *p++ = '=';
5602 }
5603
5604 return p - dst;
5605}
5606
5607/* probably should use lookup table */
5608static int
5609=====================================================================
5610Found a 39 line (180 tokens) duplication in the following files:
5611Starting at line 142 of /home/shackle/pggit/postgresql/src/bin/pg_upgrade/version.c
5612Starting at line 243 of /home/shackle/pggit/postgresql/src/bin/pg_upgrade/version.c
5613
5614 " c.relnamespace = n.oid AND "
5615 /* exclude possible orphaned temp tables */
5616 " n.nspname !~ '^pg_temp_' AND "
5617 " n.nspname !~ '^pg_toast_temp_' AND "
5618 " n.nspname NOT IN ('pg_catalog', 'information_schema')");
5619
5620 ntups = PQntuples(res);
5621 i_nspname = PQfnumber(res, "nspname");
5622 i_relname = PQfnumber(res, "relname");
5623 i_attname = PQfnumber(res, "attname");
5624 for (rowno = 0; rowno < ntups; rowno++)
5625 {
5626 found = true;
5627 if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
5628 pg_fatal("could not open file \"%s\": %s\n", output_path,
5629 strerror(errno));
5630 if (!db_used)
5631 {
5632 fprintf(script, "Database: %s\n", active_db->db_name);
5633 db_used = true;
5634 }
5635 fprintf(script, " %s.%s.%s\n",
5636 PQgetvalue(res, rowno, i_nspname),
5637 PQgetvalue(res, rowno, i_relname),
5638 PQgetvalue(res, rowno, i_attname));
5639 }
5640
5641 PQclear(res);
5642
5643 PQfinish(conn);
5644 }
5645
5646 if (script)
5647 fclose(script);
5648
5649 if (found)
5650 {
5651 pg_log(PG_REPORT, "fatal\n");
5652 pg_fatal("Your installation contains the \"line\" data type in user tables. This\n"
5653=====================================================================
5654Found a 31 line (180 tokens) duplication in the following files:
5655Starting at line 54 of /home/shackle/pggit/postgresql/src/backend/access/brin/brin_validate.c
5656Starting at line 54 of /home/shackle/pggit/postgresql/src/backend/access/nbtree/nbtvalidate.c
5657Starting at line 59 of /home/shackle/pggit/postgresql/src/backend/access/hash/hashvalidate.c
5658
5659 OpFamilyOpFuncGroup *opclassgroup;
5660 int i;
5661 ListCell *lc;
5662
5663 /* Fetch opclass information */
5664 classtup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclassoid));
5665 if (!HeapTupleIsValid(classtup))
5666 elog(ERROR, "cache lookup failed for operator class %u", opclassoid);
5667 classform = (Form_pg_opclass) GETSTRUCT(classtup);
5668
5669 opfamilyoid = classform->opcfamily;
5670 opcintype = classform->opcintype;
5671 opclassname = NameStr(classform->opcname);
5672
5673 /* Fetch opfamily information */
5674 familytup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfamilyoid));
5675 if (!HeapTupleIsValid(familytup))
5676 elog(ERROR, "cache lookup failed for operator family %u", opfamilyoid);
5677 familyform = (Form_pg_opfamily) GETSTRUCT(familytup);
5678
5679 opfamilyname = NameStr(familyform->opfname);
5680
5681 /* Fetch all operators and support functions of the opfamily */
5682 oprlist = SearchSysCacheList1(AMOPSTRATEGY, ObjectIdGetDatum(opfamilyoid));
5683 proclist = SearchSysCacheList1(AMPROCNUM, ObjectIdGetDatum(opfamilyoid));
5684
5685 /* Check individual support functions */
5686 for (i = 0; i < proclist->n_members; i++)
5687 {
5688 HeapTuple proctup = &proclist->members[i]->tuple;
5689 Form_pg_amproc procform = (Form_pg_amproc) GETSTRUCT(proctup);
5690=====================================================================
5691Found a 40 line (179 tokens) duplication in the following files:
5692Starting at line 763 of /home/shackle/pggit/postgresql/src/backend/utils/adt/jsonfuncs.c
5693Starting at line 881 of /home/shackle/pggit/postgresql/src/backend/utils/adt/jsonfuncs.c
5694
5695 VARSIZE_ANY_EXHDR(key));
5696
5697 if (v != NULL)
5698 {
5699 text *result = NULL;
5700
5701 switch (v->type)
5702 {
5703 case jbvNull:
5704 break;
5705 case jbvBool:
5706 result = cstring_to_text(v->val.boolean ? "true" : "false");
5707 break;
5708 case jbvString:
5709 result = cstring_to_text_with_len(v->val.string.val, v->val.string.len);
5710 break;
5711 case jbvNumeric:
5712 result = cstring_to_text(DatumGetCString(DirectFunctionCall1(numeric_out,
5713 PointerGetDatum(v->val.numeric))));
5714 break;
5715 case jbvBinary:
5716 {
5717 StringInfo jtext = makeStringInfo();
5718
5719 (void) JsonbToCString(jtext, v->val.binary.data, -1);
5720 result = cstring_to_text_with_len(jtext->data, jtext->len);
5721 }
5722 break;
5723 default:
5724 elog(ERROR, "unrecognized jsonb type: %d", (int) v->type);
5725 }
5726
5727 if (result)
5728 PG_RETURN_TEXT_P(result);
5729 }
5730
5731 PG_RETURN_NULL();
5732}
5733
5734Datum
5735=====================================================================
5736Found a 61 line (178 tokens) duplication in the following files:
5737Starting at line 1618 of /home/shackle/pggit/postgresql/contrib/dblink/dblink.c
5738Starting at line 1786 of /home/shackle/pggit/postgresql/contrib/dblink/dblink.c
5739
5740dblink_build_sql_insert(PG_FUNCTION_ARGS)
5741{
5742 text *relname_text = PG_GETARG_TEXT_PP(0);
5743 int2vector *pkattnums_arg = (int2vector *) PG_GETARG_POINTER(1);
5744 int32 pknumatts_arg = PG_GETARG_INT32(2);
5745 ArrayType *src_pkattvals_arry = PG_GETARG_ARRAYTYPE_P(3);
5746 ArrayType *tgt_pkattvals_arry = PG_GETARG_ARRAYTYPE_P(4);
5747 Relation rel;
5748 int *pkattnums;
5749 int pknumatts;
5750 char **src_pkattvals;
5751 char **tgt_pkattvals;
5752 int src_nitems;
5753 int tgt_nitems;
5754 char *sql;
5755
5756 /*
5757 * Open target relation.
5758 */
5759 rel = get_rel_from_relname(relname_text, AccessShareLock, ACL_SELECT);
5760
5761 /*
5762 * Process pkattnums argument.
5763 */
5764 validate_pkattnums(rel, pkattnums_arg, pknumatts_arg,
5765 &pkattnums, &pknumatts);
5766
5767 /*
5768 * Source array is made up of key values that will be used to locate the
5769 * tuple of interest from the local system.
5770 */
5771 src_pkattvals = get_text_array_contents(src_pkattvals_arry, &src_nitems);
5772
5773 /*
5774 * There should be one source array key value for each key attnum
5775 */
5776 if (src_nitems != pknumatts)
5777 ereport(ERROR,
5778 (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
5779 errmsg("source key array length must match number of key " \
5780 "attributes")));
5781
5782 /*
5783 * Target array is made up of key values that will be used to build the
5784 * SQL string for use on the remote system.
5785 */
5786 tgt_pkattvals = get_text_array_contents(tgt_pkattvals_arry, &tgt_nitems);
5787
5788 /*
5789 * There should be one target array key value for each key attnum
5790 */
5791 if (tgt_nitems != pknumatts)
5792 ereport(ERROR,
5793 (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
5794 errmsg("target key array length must match number of key " \
5795 "attributes")));
5796
5797 /*
5798 * Prep work is finally done. Go get the SQL string.
5799 */
5800 sql = get_sql_insert(rel, pkattnums, pknumatts, src_pkattvals, tgt_pkattvals);
5801=====================================================================
5802Found a 35 line (177 tokens) duplication in the following files:
5803Starting at line 1035 of /home/shackle/pggit/postgresql/src/bin/pg_upgrade/check.c
5804Starting at line 1126 of /home/shackle/pggit/postgresql/src/bin/pg_upgrade/check.c
5805Starting at line 146 of /home/shackle/pggit/postgresql/src/bin/pg_upgrade/version.c
5806Starting at line 247 of /home/shackle/pggit/postgresql/src/bin/pg_upgrade/version.c
5807
5808 " n.nspname NOT IN ('pg_catalog', 'information_schema')");
5809
5810 ntups = PQntuples(res);
5811 i_nspname = PQfnumber(res, "nspname");
5812 i_relname = PQfnumber(res, "relname");
5813 i_attname = PQfnumber(res, "attname");
5814 for (rowno = 0; rowno < ntups; rowno++)
5815 {
5816 found = true;
5817 if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
5818 pg_fatal("could not open file \"%s\": %s\n",
5819 output_path, strerror(errno));
5820 if (!db_used)
5821 {
5822 fprintf(script, "Database: %s\n", active_db->db_name);
5823 db_used = true;
5824 }
5825 fprintf(script, " %s.%s.%s\n",
5826 PQgetvalue(res, rowno, i_nspname),
5827 PQgetvalue(res, rowno, i_relname),
5828 PQgetvalue(res, rowno, i_attname));
5829 }
5830
5831 PQclear(res);
5832
5833 PQfinish(conn);
5834 }
5835
5836 if (script)
5837 fclose(script);
5838
5839 if (found)
5840 {
5841 pg_log(PG_REPORT, "fatal\n");
5842 pg_fatal("Your installation contains one of the reg* data types in user tables.\n"
5843=====================================================================
5844Found a 35 line (177 tokens) duplication in the following files:
5845Starting at line 1530 of /home/shackle/pggit/postgresql/src/backend/utils/adt/varbit.c
5846Starting at line 1610 of /home/shackle/pggit/postgresql/src/backend/utils/adt/varbit.c
5847
5848 srcbitsleft = 32;
5849 /* drop any input bits that don't fit */
5850 srcbitsleft = Min(srcbitsleft, destbitsleft);
5851 /* sign-fill any excess bytes in output */
5852 while (destbitsleft >= srcbitsleft + 8)
5853 {
5854 *r++ = (bits8) ((a < 0) ? BITMASK : 0);
5855 destbitsleft -= 8;
5856 }
5857 /* store first fractional byte */
5858 if (destbitsleft > srcbitsleft)
5859 {
5860 unsigned int val = (unsigned int) (a >> (destbitsleft - 8));
5861
5862 /* Force sign-fill in case the compiler implements >> as zero-fill */
5863 if (a < 0)
5864 val |= ((unsigned int) -1) << (srcbitsleft + 8 - destbitsleft);
5865 *r++ = (bits8) (val & BITMASK);
5866 destbitsleft -= 8;
5867 }
5868 /* Now srcbitsleft and destbitsleft are the same, need not track both */
5869 /* store whole bytes */
5870 while (destbitsleft >= 8)
5871 {
5872 *r++ = (bits8) ((a >> (destbitsleft - 8)) & BITMASK);
5873 destbitsleft -= 8;
5874 }
5875 /* store last fractional byte */
5876 if (destbitsleft > 0)
5877 *r = (bits8) ((a << (8 - destbitsleft)) & BITMASK);
5878
5879 PG_RETURN_VARBIT_P(result);
5880}
5881
5882Datum
5883=====================================================================
5884Found a 48 line (177 tokens) duplication in the following files:
5885Starting at line 2543 of /home/shackle/pggit/postgresql/src/backend/commands/trigger.c
5886Starting at line 2632 of /home/shackle/pggit/postgresql/src/backend/commands/trigger.c
5887
5888 TRIGGER_TYPE_BEFORE,
5889 TRIGGER_TYPE_INSERT))
5890 continue;
5891 if (!TriggerEnabled(estate, relinfo, trigger, LocTriggerData.tg_event,
5892 NULL, NULL, newtuple))
5893 continue;
5894
5895 LocTriggerData.tg_trigtuple = oldtuple = newtuple;
5896 LocTriggerData.tg_trigtuplebuf = InvalidBuffer;
5897 LocTriggerData.tg_trigger = trigger;
5898 newtuple = ExecCallTriggerFunc(&LocTriggerData,
5899 i,
5900 relinfo->ri_TrigFunctions,
5901 relinfo->ri_TrigInstrument,
5902 GetPerTupleMemoryContext(estate));
5903 if (oldtuple != newtuple && oldtuple != slottuple)
5904 heap_freetuple(oldtuple);
5905 if (newtuple == NULL)
5906 {
5907 if (should_free)
5908 heap_freetuple(slottuple);
5909 return NULL; /* "do nothing" */
5910 }
5911 }
5912
5913 if (newtuple != slottuple)
5914 {
5915 /*
5916 * Return the modified tuple using the es_trig_tuple_slot. We assume
5917 * the tuple was allocated in per-tuple memory context, and therefore
5918 * will go away by itself. The tuple table slot should not try to
5919 * clear it.
5920 */
5921 TupleTableSlot *newslot = estate->es_trig_tuple_slot;
5922 TupleDesc tupdesc = RelationGetDescr(relinfo->ri_RelationDesc);
5923
5924 if (newslot->tts_tupleDescriptor != tupdesc)
5925 ExecSetSlotDescriptor(newslot, tupdesc);
5926 ExecStoreHeapTuple(newtuple, newslot, false);
5927 slot = newslot;
5928 }
5929
5930 if (should_free)
5931 heap_freetuple(slottuple);
5932 return slot;
5933}
5934
5935void
5936=====================================================================
5937Found a 24 line (175 tokens) duplication in the following files:
5938Starting at line 1309 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
5939Starting at line 1625 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
5940
5941 InitFunctionCallInfoData(fcinfo, flinfo, 8, collation, NULL, NULL);
5942
5943 fcinfo.arg[0] = arg1;
5944 fcinfo.arg[1] = arg2;
5945 fcinfo.arg[2] = arg3;
5946 fcinfo.arg[3] = arg4;
5947 fcinfo.arg[4] = arg5;
5948 fcinfo.arg[5] = arg6;
5949 fcinfo.arg[6] = arg7;
5950 fcinfo.arg[7] = arg8;
5951 fcinfo.argnull[0] = false;
5952 fcinfo.argnull[1] = false;
5953 fcinfo.argnull[2] = false;
5954 fcinfo.argnull[3] = false;
5955 fcinfo.argnull[4] = false;
5956 fcinfo.argnull[5] = false;
5957 fcinfo.argnull[6] = false;
5958 fcinfo.argnull[7] = false;
5959
5960 result = FunctionCallInvoke(&fcinfo);
5961
5962 /* Check for null result, since caller is clearly not expecting one */
5963 if (fcinfo.isnull)
5964 elog(ERROR, "function %u returned NULL", fcinfo.flinfo->fn_oid);
5965=====================================================================
5966Found a 22 line (174 tokens) duplication in the following files:
5967Starting at line 1026 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
5968Starting at line 1346 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
5969Starting at line 1665 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
5970
5971 InitFunctionCallInfoData(fcinfo, NULL, 9, collation, NULL, NULL);
5972
5973 fcinfo.arg[0] = arg1;
5974 fcinfo.arg[1] = arg2;
5975 fcinfo.arg[2] = arg3;
5976 fcinfo.arg[3] = arg4;
5977 fcinfo.arg[4] = arg5;
5978 fcinfo.arg[5] = arg6;
5979 fcinfo.arg[6] = arg7;
5980 fcinfo.arg[7] = arg8;
5981 fcinfo.arg[8] = arg9;
5982 fcinfo.argnull[0] = false;
5983 fcinfo.argnull[1] = false;
5984 fcinfo.argnull[2] = false;
5985 fcinfo.argnull[3] = false;
5986 fcinfo.argnull[4] = false;
5987 fcinfo.argnull[5] = false;
5988 fcinfo.argnull[6] = false;
5989 fcinfo.argnull[7] = false;
5990 fcinfo.argnull[8] = false;
5991
5992 result = (*func) (&fcinfo);
5993=====================================================================
5994Found a 37 line (173 tokens) duplication in the following files:
5995Starting at line 158 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/interval.c
5996Starting at line 3553 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
5997
5998 tm->tm_mon += (fval * 12);
5999 break;
6000 case 'M':
6001 tm->tm_mon += val;
6002 AdjustFractDays(fval, tm, fsec, DAYS_PER_MONTH);
6003 break;
6004 case 'W':
6005 tm->tm_mday += val * 7;
6006 AdjustFractDays(fval, tm, fsec, 7);
6007 break;
6008 case 'D':
6009 tm->tm_mday += val;
6010 AdjustFractSeconds(fval, tm, fsec, SECS_PER_DAY);
6011 break;
6012 case 'T': /* ISO 8601 4.4.3.3 Alternative Format / Basic */
6013 case '\0':
6014 if (ISO8601IntegerWidth(fieldstart) == 8 && !havefield)
6015 {
6016 tm->tm_year += val / 10000;
6017 tm->tm_mon += (val / 100) % 100;
6018 tm->tm_mday += val % 100;
6019 AdjustFractSeconds(fval, tm, fsec, SECS_PER_DAY);
6020 if (unit == '\0')
6021 return 0;
6022 datepart = false;
6023 havefield = false;
6024 continue;
6025 }
6026 /* Else fall through to extended alternative format */
6027 /* FALLTHROUGH */
6028 case '-': /* ISO 8601 4.4.3.3 Alternative Format,
6029 * Extended */
6030 if (havefield)
6031 return DTERR_BAD_FORMAT;
6032
6033 tm->tm_year += val;
6034 tm->tm_mon += (fval * 12);
6035=====================================================================
6036Found a 33 line (172 tokens) duplication in the following files:
6037Starting at line 694 of /home/shackle/pggit/postgresql/contrib/dblink/dblink.c
6038Starting at line 1401 of /home/shackle/pggit/postgresql/contrib/dblink/dblink.c
6039
6040 if (PG_NARGS() == 3)
6041 {
6042 /* text,text,bool */
6043 conname = text_to_cstring(PG_GETARG_TEXT_PP(0));
6044 sql = text_to_cstring(PG_GETARG_TEXT_PP(1));
6045 fail = PG_GETARG_BOOL(2);
6046 dblink_get_conn(conname, &conn, &conname, &freeconn);
6047 }
6048 else if (PG_NARGS() == 2)
6049 {
6050 /* text,text or text,bool */
6051 if (get_fn_expr_argtype(fcinfo->flinfo, 1) == BOOLOID)
6052 {
6053 sql = text_to_cstring(PG_GETARG_TEXT_PP(0));
6054 fail = PG_GETARG_BOOL(1);
6055 conn = pconn->conn;
6056 }
6057 else
6058 {
6059 conname = text_to_cstring(PG_GETARG_TEXT_PP(0));
6060 sql = text_to_cstring(PG_GETARG_TEXT_PP(1));
6061 dblink_get_conn(conname, &conn, &conname, &freeconn);
6062 }
6063 }
6064 else if (PG_NARGS() == 1)
6065 {
6066 /* text */
6067 conn = pconn->conn;
6068 sql = text_to_cstring(PG_GETARG_TEXT_PP(0));
6069 }
6070 else
6071 /* shouldn't happen */
6072 elog(ERROR, "wrong number of arguments");
6073=====================================================================
6074Found a 48 line (172 tokens) duplication in the following files:
6075Starting at line 883 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
6076Starting at line 1127 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
6077
6078 Oid collation;
6079
6080 /*
6081 * Skip dropped columns
6082 */
6083 if (i1 < ncolumns1 && TupleDescAttr(tupdesc1, i1)->attisdropped)
6084 {
6085 i1++;
6086 continue;
6087 }
6088 if (i2 < ncolumns2 && TupleDescAttr(tupdesc2, i2)->attisdropped)
6089 {
6090 i2++;
6091 continue;
6092 }
6093 if (i1 >= ncolumns1 || i2 >= ncolumns2)
6094 break; /* we'll deal with mismatch below loop */
6095
6096 att1 = TupleDescAttr(tupdesc1, i1);
6097 att2 = TupleDescAttr(tupdesc2, i2);
6098
6099 /*
6100 * Have two matching columns, they must be same type
6101 */
6102 if (att1->atttypid != att2->atttypid)
6103 ereport(ERROR,
6104 (errcode(ERRCODE_DATATYPE_MISMATCH),
6105 errmsg("cannot compare dissimilar column types %s and %s at record column %d",
6106 format_type_be(att1->atttypid),
6107 format_type_be(att2->atttypid),
6108 j + 1)));
6109
6110 /*
6111 * If they're not same collation, we don't complain here, but the
6112 * comparison function might.
6113 */
6114 collation = att1->attcollation;
6115 if (collation != att2->attcollation)
6116 collation = InvalidOid;
6117
6118 /*
6119 * Lookup the comparison function if not done already
6120 */
6121 typentry = my_extra->columns[j].typentry;
6122 if (typentry == NULL ||
6123 typentry->type_id != att1->atttypid)
6124 {
6125 typentry = lookup_type_cache(att1->atttypid,
6126=====================================================================
6127Found a 14 line (171 tokens) duplication in the following files:
6128Starting at line 1737 of /home/shackle/pggit/postgresql/src/backend/utils/mb/wchar.c
6129Starting at line 1752 of /home/shackle/pggit/postgresql/src/backend/utils/mb/wchar.c
6130
6131 {pg_mule2wchar_with_len, pg_wchar2mule_with_len, pg_mule_mblen, pg_mule_dsplen, pg_mule_verifier, 4}, /* PG_MULE_INTERNAL */
6132 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN1 */
6133 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN2 */
6134 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN3 */
6135 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN4 */
6136 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN5 */
6137 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN6 */
6138 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN7 */
6139 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN8 */
6140 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN9 */
6141 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN10 */
6142 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_WIN1256 */
6143 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_WIN1258 */
6144 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_WIN866 */
6145=====================================================================
6146Found a 52 line (171 tokens) duplication in the following files:
6147Starting at line 4549 of /home/shackle/pggit/postgresql/src/backend/utils/adt/timestamp.c
6148Starting at line 4765 of /home/shackle/pggit/postgresql/src/backend/utils/adt/timestamp.c
6149
6150 case DTK_MICROSEC:
6151 result = tm->tm_sec * 1000000.0 + fsec;
6152 break;
6153
6154 case DTK_MILLISEC:
6155 result = tm->tm_sec * 1000.0 + fsec / 1000.0;
6156 break;
6157
6158 case DTK_SECOND:
6159 result = tm->tm_sec + fsec / 1000000.0;
6160 break;
6161
6162 case DTK_MINUTE:
6163 result = tm->tm_min;
6164 break;
6165
6166 case DTK_HOUR:
6167 result = tm->tm_hour;
6168 break;
6169
6170 case DTK_DAY:
6171 result = tm->tm_mday;
6172 break;
6173
6174 case DTK_MONTH:
6175 result = tm->tm_mon;
6176 break;
6177
6178 case DTK_QUARTER:
6179 result = (tm->tm_mon - 1) / 3 + 1;
6180 break;
6181
6182 case DTK_WEEK:
6183 result = (float8) date2isoweek(tm->tm_year, tm->tm_mon, tm->tm_mday);
6184 break;
6185
6186 case DTK_YEAR:
6187 if (tm->tm_year > 0)
6188 result = tm->tm_year;
6189 else
6190 /* there is no year 0, just 1 BC and 1 AD */
6191 result = tm->tm_year - 1;
6192 break;
6193
6194 case DTK_DECADE:
6195
6196 /*
6197 * what is a decade wrt dates? let us assume that decade 199
6198 * is 1990 thru 1999... decade 0 starts on year 1 BC, and -1
6199 * is 11 BC thru 2 BC...
6200 */
6201 if (tm->tm_year >= 0)
6202=====================================================================
6203Found a 34 line (170 tokens) duplication in the following files:
6204Starting at line 360 of /home/shackle/pggit/postgresql/contrib/hstore/hstore_gist.c
6205Starting at line 302 of /home/shackle/pggit/postgresql/contrib/ltree/_ltree_gist.c
6206
6207 *_j;
6208
6209 nbytes = (maxoff + 2) * sizeof(OffsetNumber);
6210 v->spl_left = (OffsetNumber *) palloc(nbytes);
6211 v->spl_right = (OffsetNumber *) palloc(nbytes);
6212
6213 for (k = FirstOffsetNumber; k < maxoff; k = OffsetNumberNext(k))
6214 {
6215 _k = GETENTRY(entryvec, k);
6216 for (j = OffsetNumberNext(k); j <= maxoff; j = OffsetNumberNext(j))
6217 {
6218 size_waste = hemdist(_k, GETENTRY(entryvec, j));
6219 if (size_waste > waste)
6220 {
6221 waste = size_waste;
6222 seed_1 = k;
6223 seed_2 = j;
6224 }
6225 }
6226 }
6227
6228 left = v->spl_left;
6229 v->spl_nleft = 0;
6230 right = v->spl_right;
6231 v->spl_nright = 0;
6232
6233 if (seed_1 == 0 || seed_2 == 0)
6234 {
6235 seed_1 = 1;
6236 seed_2 = 2;
6237 }
6238
6239 /* form initial .. */
6240 if (ISALLTRUE(GETENTRY(entryvec, seed_1)))
6241=====================================================================
6242Found a 46 line (170 tokens) duplication in the following files:
6243Starting at line 33 of /home/shackle/pggit/postgresql/src/test/examples/testlo64.c
6244Starting at line 33 of /home/shackle/pggit/postgresql/src/test/examples/testlo.c
6245
6246static Oid
6247importFile(PGconn *conn, char *filename)
6248{
6249 Oid lobjId;
6250 int lobj_fd;
6251 char buf[BUFSIZE];
6252 int nbytes,
6253 tmp;
6254 int fd;
6255
6256 /*
6257 * open the file to be read in
6258 */
6259 fd = open(filename, O_RDONLY, 0666);
6260 if (fd < 0)
6261 { /* error */
6262 fprintf(stderr, "cannot open unix file\"%s\"\n", filename);
6263 }
6264
6265 /*
6266 * create the large object
6267 */
6268 lobjId = lo_creat(conn, INV_READ | INV_WRITE);
6269 if (lobjId == 0)
6270 fprintf(stderr, "cannot create large object");
6271
6272 lobj_fd = lo_open(conn, lobjId, INV_WRITE);
6273
6274 /*
6275 * read in from the Unix file and write to the inversion file
6276 */
6277 while ((nbytes = read(fd, buf, BUFSIZE)) > 0)
6278 {
6279 tmp = lo_write(conn, lobj_fd, buf, nbytes);
6280 if (tmp < nbytes)
6281 fprintf(stderr, "error while reading \"%s\"", filename);
6282 }
6283
6284 close(fd);
6285 lo_close(conn, lobj_fd);
6286
6287 return lobjId;
6288}
6289
6290static void
6291pickout(PGconn *conn, Oid lobjId, pg_int64 start, int len)
6292=====================================================================
6293Found a 26 line (170 tokens) duplication in the following files:
6294Starting at line 899 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/interval.c
6295Starting at line 4374 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
6296
6297 AppendSeconds(cp, sec, fsec, MAX_INTERVAL_PRECISION, true);
6298 }
6299 break;
6300
6301 /* Compatible with postgresql < 8.4 when DateStyle != 'iso' */
6302 case INTSTYLE_POSTGRES_VERBOSE:
6303 default:
6304 strcpy(cp, "@");
6305 cp++;
6306 cp = AddVerboseIntPart(cp, year, "year", &is_zero, &is_before);
6307 cp = AddVerboseIntPart(cp, mon, "mon", &is_zero, &is_before);
6308 cp = AddVerboseIntPart(cp, mday, "day", &is_zero, &is_before);
6309 cp = AddVerboseIntPart(cp, hour, "hour", &is_zero, &is_before);
6310 cp = AddVerboseIntPart(cp, min, "min", &is_zero, &is_before);
6311 if (sec != 0 || fsec != 0)
6312 {
6313 *cp++ = ' ';
6314 if (sec < 0 || (sec == 0 && fsec < 0))
6315 {
6316 if (is_zero)
6317 is_before = true;
6318 else if (!is_before)
6319 *cp++ = '-';
6320 }
6321 else if (is_before)
6322 *cp++ = '-';
6323=====================================================================
6324Found a 41 line (170 tokens) duplication in the following files:
6325Starting at line 1156 of /home/shackle/pggit/postgresql/src/backend/storage/lmgr/lock.c
6326Starting at line 4100 of /home/shackle/pggit/postgresql/src/backend/storage/lmgr/lock.c
6327
6328 LOCK_PRINT("LockAcquire: found", lock, lockmode);
6329 Assert((lock->nRequested >= 0) && (lock->requested[lockmode] >= 0));
6330 Assert((lock->nGranted >= 0) && (lock->granted[lockmode] >= 0));
6331 Assert(lock->nGranted <= lock->nRequested);
6332 }
6333
6334 /*
6335 * Create the hash key for the proclock table.
6336 */
6337 proclocktag.myLock = lock;
6338 proclocktag.myProc = proc;
6339
6340 proclock_hashcode = ProcLockHashCode(&proclocktag, hashcode);
6341
6342 /*
6343 * Find or create a proclock entry with this tag
6344 */
6345 proclock = (PROCLOCK *) hash_search_with_hash_value(LockMethodProcLockHash,
6346 (void *) &proclocktag,
6347 proclock_hashcode,
6348 HASH_ENTER_NULL,
6349 &found);
6350 if (!proclock)
6351 {
6352 /* Oops, not enough shmem for the proclock */
6353 if (lock->nRequested == 0)
6354 {
6355 /*
6356 * There are no other requestors of this lock, so garbage-collect
6357 * the lock object. We *must* do this to avoid a permanent leak
6358 * of shared memory, because there won't be anything to cause
6359 * anyone to release the lock object later.
6360 */
6361 Assert(SHMQueueEmpty(&(lock->procLocks)));
6362 if (!hash_search_with_hash_value(LockMethodLockHash,
6363 (void *) &(lock->tag),
6364 hashcode,
6365 HASH_REMOVE,
6366 NULL))
6367 elog(PANIC, "lock table corrupted");
6368 }
6369=====================================================================
6370Found a 48 line (170 tokens) duplication in the following files:
6371Starting at line 367 of /home/shackle/pggit/postgresql/src/backend/access/common/indextuple.c
6372Starting at line 570 of /home/shackle/pggit/postgresql/src/backend/access/common/heaptuple.c
6373
6374 if (IndexTupleHasNulls(tup) && att_isnull(i, bp))
6375 {
6376 usecache = false;
6377 continue; /* this cannot be the target att */
6378 }
6379
6380 /* If we know the next offset, we can skip the rest */
6381 if (usecache && att->attcacheoff >= 0)
6382 off = att->attcacheoff;
6383 else if (att->attlen == -1)
6384 {
6385 /*
6386 * We can only cache the offset for a varlena attribute if the
6387 * offset is already suitably aligned, so that there would be
6388 * no pad bytes in any case: then the offset will be valid for
6389 * either an aligned or unaligned value.
6390 */
6391 if (usecache &&
6392 off == att_align_nominal(off, att->attalign))
6393 att->attcacheoff = off;
6394 else
6395 {
6396 off = att_align_pointer(off, att->attalign, -1,
6397 tp + off);
6398 usecache = false;
6399 }
6400 }
6401 else
6402 {
6403 /* not varlena, so safe to use att_align_nominal */
6404 off = att_align_nominal(off, att->attalign);
6405
6406 if (usecache)
6407 att->attcacheoff = off;
6408 }
6409
6410 if (i == attnum)
6411 break;
6412
6413 off = att_addlength_pointer(off, att->attlen, tp + off);
6414
6415 if (usecache && att->attlen <= 0)
6416 usecache = false;
6417 }
6418 }
6419
6420 return fetchatt(TupleDescAttr(tupleDesc, attnum), tp + off);
6421}
6422=====================================================================
6423Found a 53 line (169 tokens) duplication in the following files:
6424Starting at line 372 of /home/shackle/pggit/postgresql/src/backend/utils/time/tqual.c
6425Starting at line 748 of /home/shackle/pggit/postgresql/src/backend/utils/time/tqual.c
6426
6427 Assert(htup->t_tableOid != InvalidOid);
6428
6429 if (!HeapTupleHeaderXminCommitted(tuple))
6430 {
6431 if (HeapTupleHeaderXminInvalid(tuple))
6432 return false;
6433
6434 /* Used by pre-9.0 binary upgrades */
6435 if (tuple->t_infomask & HEAP_MOVED_OFF)
6436 {
6437 TransactionId xvac = HeapTupleHeaderGetXvac(tuple);
6438
6439 if (TransactionIdIsCurrentTransactionId(xvac))
6440 return false;
6441 if (!TransactionIdIsInProgress(xvac))
6442 {
6443 if (TransactionIdDidCommit(xvac))
6444 {
6445 SetHintBits(tuple, buffer, HEAP_XMIN_INVALID,
6446 InvalidTransactionId);
6447 return false;
6448 }
6449 SetHintBits(tuple, buffer, HEAP_XMIN_COMMITTED,
6450 InvalidTransactionId);
6451 }
6452 }
6453 /* Used by pre-9.0 binary upgrades */
6454 else if (tuple->t_infomask & HEAP_MOVED_IN)
6455 {
6456 TransactionId xvac = HeapTupleHeaderGetXvac(tuple);
6457
6458 if (!TransactionIdIsCurrentTransactionId(xvac))
6459 {
6460 if (TransactionIdIsInProgress(xvac))
6461 return false;
6462 if (TransactionIdDidCommit(xvac))
6463 SetHintBits(tuple, buffer, HEAP_XMIN_COMMITTED,
6464 InvalidTransactionId);
6465 else
6466 {
6467 SetHintBits(tuple, buffer, HEAP_XMIN_INVALID,
6468 InvalidTransactionId);
6469 return false;
6470 }
6471 }
6472 }
6473
6474 /*
6475 * An invalid Xmin can be left behind by a speculative insertion that
6476 * is canceled by super-deleting the tuple. This also applies to
6477 * TOAST tuples created during speculative insertion.
6478 */
6479 else if (!TransactionIdIsValid(HeapTupleHeaderGetXmin(tuple)))
6480=====================================================================
6481Found a 17 line (168 tokens) duplication in the following files:
6482Starting at line 246 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
6483Starting at line 289 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
6484
6485 { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 from $0",
6486 ECPGt_int,&(count),(long)1,(long)1,sizeof(int),
6487 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
6488 ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
6489 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
6490 ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
6491 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
6492 ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
6493 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
6494#line 83 "cursor.pgc"
6495
6496if (sqlca.sqlcode < 0) exit (1);}
6497#line 83 "cursor.pgc"
6498
6499 printf("%d %s\n", id, t);
6500
6501 strcpy(msg, "move in");
6502=====================================================================
6503Found a 17 line (168 tokens) duplication in the following files:
6504Starting at line 386 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
6505Starting at line 433 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
6506
6507 { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 from $0",
6508 ECPGt_int,&(count),(long)1,(long)1,sizeof(int),
6509 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
6510 ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
6511 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
6512 ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
6513 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
6514 ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
6515 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
6516#line 124 "cursor.pgc"
6517
6518if (sqlca.sqlcode < 0) exit (1);}
6519#line 124 "cursor.pgc"
6520
6521 printf("%d %s\n", id, t);
6522
6523 strcpy(msg, "move");
6524=====================================================================
6525Found a 17 line (168 tokens) duplication in the following files:
6526Starting at line 554 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
6527Starting at line 597 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
6528
6529 { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 from $0",
6530 ECPGt_int,&(count),(long)1,(long)1,sizeof(int),
6531 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
6532 ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char),
6533 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
6534 ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
6535 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
6536 ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
6537 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
6538#line 170 "cursor.pgc"
6539
6540if (sqlca.sqlcode < 0) exit (1);}
6541#line 170 "cursor.pgc"
6542
6543 printf("%d %s\n", id, t);
6544
6545 strcpy(msg, "move");
6546=====================================================================
6547Found a 35 line (168 tokens) duplication in the following files:
6548Starting at line 889 of /home/shackle/pggit/postgresql/src/backend/utils/mmgr/mcxt.c
6549Starting at line 992 of /home/shackle/pggit/postgresql/src/backend/utils/mmgr/mcxt.c
6550
6551 void *ret;
6552
6553 AssertArg(MemoryContextIsValid(context));
6554 AssertNotInCriticalSection(context);
6555
6556 if (((flags & MCXT_ALLOC_HUGE) != 0 && !AllocHugeSizeIsValid(size)) ||
6557 ((flags & MCXT_ALLOC_HUGE) == 0 && !AllocSizeIsValid(size)))
6558 elog(ERROR, "invalid memory alloc request size %zu", size);
6559
6560 context->isReset = false;
6561
6562 ret = context->methods->alloc(context, size);
6563 if (unlikely(ret == NULL))
6564 {
6565 if ((flags & MCXT_ALLOC_NO_OOM) == 0)
6566 {
6567 MemoryContextStats(TopMemoryContext);
6568 ereport(ERROR,
6569 (errcode(ERRCODE_OUT_OF_MEMORY),
6570 errmsg("out of memory"),
6571 errdetail("Failed on request of size %zu in memory context \"%s\".",
6572 size, context->name)));
6573 }
6574 return NULL;
6575 }
6576
6577 VALGRIND_MEMPOOL_ALLOC(context, ret, size);
6578
6579 if ((flags & MCXT_ALLOC_ZERO) != 0)
6580 MemSetAligned(ret, 0, size);
6581
6582 return ret;
6583}
6584
6585void *
6586=====================================================================
6587Found a 18 line (167 tokens) duplication in the following files:
6588Starting at line 231 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
6589Starting at line 371 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
6590Starting at line 539 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
6591Starting at line 709 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
6592
6593 ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
6594 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
6595 ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
6596 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
6597 ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
6598 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
6599#line 78 "cursor.pgc"
6600
6601if (sqlca.sqlcode < 0) exit (1);}
6602#line 78 "cursor.pgc"
6603
6604 printf("%d %s\n", id, t);
6605
6606 strcpy(msg, "fetch :count from");
6607 count = 1;
6608 { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 from $0",
6609 ECPGt_int,&(count),(long)1,(long)1,sizeof(int),
6610 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
6611=====================================================================
6612Found a 18 line (167 tokens) duplication in the following files:
6613Starting at line 274 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
6614Starting at line 418 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
6615Starting at line 582 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
6616Starting at line 752 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
6617
6618 ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
6619 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
6620 ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
6621 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
6622 ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
6623 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
6624#line 90 "cursor.pgc"
6625
6626if (sqlca.sqlcode < 0) exit (1);}
6627#line 90 "cursor.pgc"
6628
6629 printf("%d %s\n", id, t);
6630
6631 strcpy(msg, "fetch :count");
6632 count = 1;
6633 { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 $0",
6634 ECPGt_int,&(count),(long)1,(long)1,sizeof(int),
6635 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
6636=====================================================================
6637Found a 32 line (167 tokens) duplication in the following files:
6638Starting at line 111 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
6639Starting at line 328 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
6640Starting at line 484 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
6641Starting at line 675 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
6642
6643 ncolumns = tupdesc->natts;
6644
6645 /*
6646 * We arrange to look up the needed I/O info just once per series of
6647 * calls, assuming the record type doesn't change underneath us.
6648 */
6649 my_extra = (RecordIOData *) fcinfo->flinfo->fn_extra;
6650 if (my_extra == NULL ||
6651 my_extra->ncolumns != ncolumns)
6652 {
6653 fcinfo->flinfo->fn_extra =
6654 MemoryContextAlloc(fcinfo->flinfo->fn_mcxt,
6655 offsetof(RecordIOData, columns) +
6656 ncolumns * sizeof(ColumnIOData));
6657 my_extra = (RecordIOData *) fcinfo->flinfo->fn_extra;
6658 my_extra->record_type = InvalidOid;
6659 my_extra->record_typmod = 0;
6660 }
6661
6662 if (my_extra->record_type != tupType ||
6663 my_extra->record_typmod != tupTypmod)
6664 {
6665 MemSet(my_extra, 0,
6666 offsetof(RecordIOData, columns) +
6667 ncolumns * sizeof(ColumnIOData));
6668 my_extra->record_type = tupType;
6669 my_extra->record_typmod = tupTypmod;
6670 my_extra->ncolumns = ncolumns;
6671 }
6672
6673 values = (Datum *) palloc(ncolumns * sizeof(Datum));
6674 nulls = (bool *) palloc(ncolumns * sizeof(bool));
6675=====================================================================
6676Found a 25 line (166 tokens) duplication in the following files:
6677Starting at line 4765 of /home/shackle/pggit/postgresql/src/backend/utils/adt/ruleutils.c
6678Starting at line 4948 of /home/shackle/pggit/postgresql/src/backend/utils/adt/ruleutils.c
6679
6680 rulename = NameStr(*(DatumGetName(dat)));
6681
6682 fno = SPI_fnumber(rulettc, "ev_type");
6683 dat = SPI_getbinval(ruletup, rulettc, fno, &isnull);
6684 Assert(!isnull);
6685 ev_type = DatumGetChar(dat);
6686
6687 fno = SPI_fnumber(rulettc, "ev_class");
6688 dat = SPI_getbinval(ruletup, rulettc, fno, &isnull);
6689 Assert(!isnull);
6690 ev_class = DatumGetObjectId(dat);
6691
6692 fno = SPI_fnumber(rulettc, "is_instead");
6693 dat = SPI_getbinval(ruletup, rulettc, fno, &isnull);
6694 Assert(!isnull);
6695 is_instead = DatumGetBool(dat);
6696
6697 /* these could be nulls */
6698 fno = SPI_fnumber(rulettc, "ev_qual");
6699 ev_qual = SPI_getvalue(ruletup, rulettc, fno);
6700
6701 fno = SPI_fnumber(rulettc, "ev_action");
6702 ev_action = SPI_getvalue(ruletup, rulettc, fno);
6703 if (ev_action != NULL)
6704 actions = (List *) stringToNode(ev_action);
6705=====================================================================
6706Found a 17 line (165 tokens) duplication in the following files:
6707Starting at line 724 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
6708Starting at line 767 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
6709
6710 { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 from $0",
6711 ECPGt_int,&(count),(long)1,(long)1,sizeof(int),
6712 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
6713 ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1),
6714 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
6715 ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
6716 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
6717 ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
6718 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
6719#line 222 "cursor.pgc"
6720
6721if (sqlca.sqlcode < 0) exit (1);}
6722#line 222 "cursor.pgc"
6723
6724 printf("%d %s\n", id, t);
6725
6726 strcpy(msg, "move");
6727=====================================================================
6728Found a 17 line (164 tokens) duplication in the following files:
6729Starting at line 221 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-array.c
6730Starting at line 242 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-array.c
6731
6732 ECPGt_char,(text),(long)25,(long)1,(25)*sizeof(char),
6733 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
6734 ECPGt_timestamp,&(ts),(long)1,(long)10,sizeof(timestamp),
6735 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
6736 ECPGt_numeric,&(n),(long)1,(long)10,sizeof(numeric),
6737 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
6738 ECPGt_date,&(d),(long)1,(long)10,sizeof(date),
6739 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
6740 ECPGt_interval,&(in),(long)1,(long)10,sizeof(interval),
6741 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
6742#line 63 "array.pgc"
6743
6744if (sqlca.sqlcode < 0) sqlprint();}
6745#line 63 "array.pgc"
6746
6747
6748 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test ( f , i , a , text , ts , n , d , inter ) values ( 14.07 , $1 , $2 , $3 , $4 , $5 , $6 , $7 )",
6749=====================================================================
6750Found a 49 line (162 tokens) duplication in the following files:
6751Starting at line 1788 of /home/shackle/pggit/postgresql/contrib/postgres_fdw/postgres_fdw.c
6752Starting at line 1863 of /home/shackle/pggit/postgresql/contrib/postgres_fdw/postgres_fdw.c
6753
6754 p_values = convert_prep_stmt_params(fmstate, NULL, slot);
6755
6756 /*
6757 * Execute the prepared statement.
6758 */
6759 if (!PQsendQueryPrepared(fmstate->conn,
6760 fmstate->p_name,
6761 fmstate->p_nums,
6762 p_values,
6763 NULL,
6764 NULL,
6765 0))
6766 pgfdw_report_error(ERROR, NULL, fmstate->conn, false, fmstate->query);
6767
6768 /*
6769 * Get the result, and check for success.
6770 *
6771 * We don't use a PG_TRY block here, so be careful not to throw error
6772 * without releasing the PGresult.
6773 */
6774 res = pgfdw_get_result(fmstate->conn, fmstate->query);
6775 if (PQresultStatus(res) !=
6776 (fmstate->has_returning ? PGRES_TUPLES_OK : PGRES_COMMAND_OK))
6777 pgfdw_report_error(ERROR, res, fmstate->conn, true, fmstate->query);
6778
6779 /* Check number of rows affected, and fetch RETURNING tuple if any */
6780 if (fmstate->has_returning)
6781 {
6782 n_rows = PQntuples(res);
6783 if (n_rows > 0)
6784 store_returning_result(fmstate, slot, res);
6785 }
6786 else
6787 n_rows = atoi(PQcmdTuples(res));
6788
6789 /* And clean up */
6790 PQclear(res);
6791
6792 MemoryContextReset(fmstate->temp_cxt);
6793
6794 /* Return NULL if nothing was inserted on the remote end */
6795 return (n_rows > 0) ? slot : NULL;
6796}
6797
6798/*
6799 * postgresExecForeignUpdate
6800 * Update one row in a foreign table
6801 */
6802static TupleTableSlot *
6803=====================================================================
6804Found a 48 line (162 tokens) duplication in the following files:
6805Starting at line 1986 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/dt_common.c
6806Starting at line 1005 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
6807Starting at line 1912 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
6808
6809 return -1;
6810
6811 switch (ptype)
6812 {
6813 case DTK_YEAR:
6814 tm->tm_year = val;
6815 tmask = DTK_M(YEAR);
6816 break;
6817
6818 case DTK_MONTH:
6819
6820 /*
6821 * already have a month and hour? then assume
6822 * minutes
6823 */
6824 if ((fmask & DTK_M(MONTH)) != 0 &&
6825 (fmask & DTK_M(HOUR)) != 0)
6826 {
6827 tm->tm_min = val;
6828 tmask = DTK_M(MINUTE);
6829 }
6830 else
6831 {
6832 tm->tm_mon = val;
6833 tmask = DTK_M(MONTH);
6834 }
6835 break;
6836
6837 case DTK_DAY:
6838 tm->tm_mday = val;
6839 tmask = DTK_M(DAY);
6840 break;
6841
6842 case DTK_HOUR:
6843 tm->tm_hour = val;
6844 tmask = DTK_M(HOUR);
6845 break;
6846
6847 case DTK_MINUTE:
6848 tm->tm_min = val;
6849 tmask = DTK_M(MINUTE);
6850 break;
6851
6852 case DTK_SECOND:
6853 tm->tm_sec = val;
6854 tmask = DTK_M(SECOND);
6855 if (*cp == '.')
6856 {
6857=====================================================================
6858Found a 16 line (162 tokens) duplication in the following files:
6859Starting at line 203 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-array.c
6860Starting at line 222 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-array.c
6861
6862 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test ( f , i , a , text , ts , n , d , inter ) values ( 404.90 , 3 , '{0,1,2,3,4,5,6,7,8,9}' , 'abcdefghij' , $1 , $2 , $3 , $4 )",
6863 ECPGt_timestamp,&(ts),(long)1,(long)10,sizeof(timestamp),
6864 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
6865 ECPGt_numeric,&(n),(long)1,(long)10,sizeof(numeric),
6866 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
6867 ECPGt_date,&(d),(long)1,(long)10,sizeof(date),
6868 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
6869 ECPGt_interval,&(in),(long)1,(long)10,sizeof(interval),
6870 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
6871#line 61 "array.pgc"
6872
6873if (sqlca.sqlcode < 0) sqlprint();}
6874#line 61 "array.pgc"
6875
6876
6877 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test ( f , i , a , text , ts , n , d , inter ) values ( 140787.0 , 2 , $1 , $2 , $3 , $4 , $5 , $6 )",
6878=====================================================================
6879Found a 29 line (161 tokens) duplication in the following files:
6880Starting at line 1272 of /home/shackle/pggit/postgresql/contrib/hstore/hstore_io.c
6881Starting at line 1327 of /home/shackle/pggit/postgresql/contrib/hstore/hstore_io.c
6882
6883hstore_to_json_loose(PG_FUNCTION_ARGS)
6884{
6885 HStore *in = PG_GETARG_HSTORE_P(0);
6886 int i;
6887 int count = HS_COUNT(in);
6888 char *base = STRPTR(in);
6889 HEntry *entries = ARRPTR(in);
6890 StringInfoData tmp,
6891 dst;
6892
6893 if (count == 0)
6894 PG_RETURN_TEXT_P(cstring_to_text_with_len("{}", 2));
6895
6896 initStringInfo(&tmp);
6897 initStringInfo(&dst);
6898
6899 appendStringInfoChar(&dst, '{');
6900
6901 for (i = 0; i < count; i++)
6902 {
6903 resetStringInfo(&tmp);
6904 appendBinaryStringInfo(&tmp, HSTORE_KEY(entries, base, i),
6905 HSTORE_KEYLEN(entries, i));
6906 escape_json(&dst, tmp.data);
6907 appendStringInfoString(&dst, ": ");
6908 if (HSTORE_VALISNULL(entries, i))
6909 appendStringInfoString(&dst, "null");
6910 /* guess that values of 't' or 'f' are booleans */
6911 else if (HSTORE_VALLEN(entries, i) == 1 &&
6912=====================================================================
6913Found a 26 line (161 tokens) duplication in the following files:
6914Starting at line 852 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/interval.c
6915Starting at line 4321 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
6916
6917 AppendSeconds(cp, sec, fsec, MAX_INTERVAL_PRECISION, true);
6918 }
6919 }
6920 break;
6921
6922 /* ISO 8601 "time-intervals by duration only" */
6923 case INTSTYLE_ISO_8601:
6924 /* special-case zero to avoid printing nothing */
6925 if (year == 0 && mon == 0 && mday == 0 &&
6926 hour == 0 && min == 0 && sec == 0 && fsec == 0)
6927 {
6928 sprintf(cp, "PT0S");
6929 break;
6930 }
6931 *cp++ = 'P';
6932 cp = AddISO8601IntPart(cp, year, 'Y');
6933 cp = AddISO8601IntPart(cp, mon, 'M');
6934 cp = AddISO8601IntPart(cp, mday, 'D');
6935 if (hour != 0 || min != 0 || sec != 0 || fsec != 0)
6936 *cp++ = 'T';
6937 cp = AddISO8601IntPart(cp, hour, 'H');
6938 cp = AddISO8601IntPart(cp, min, 'M');
6939 if (sec != 0 || fsec != 0)
6940 {
6941 if (sec < 0 || fsec < 0)
6942 *cp++ = '-';
6943=====================================================================
6944Found a 20 line (161 tokens) duplication in the following files:
6945Starting at line 2834 of /home/shackle/pggit/postgresql/src/backend/utils/adt/timestamp.c
6946Starting at line 2940 of /home/shackle/pggit/postgresql/src/backend/utils/adt/timestamp.c
6947
6948 if (timestamp2tm(timestamp, NULL, tm, &fsec, NULL, NULL) != 0)
6949 ereport(ERROR,
6950 (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
6951 errmsg("timestamp out of range")));
6952
6953 tm->tm_mon += span->month;
6954 if (tm->tm_mon > MONTHS_PER_YEAR)
6955 {
6956 tm->tm_year += (tm->tm_mon - 1) / MONTHS_PER_YEAR;
6957 tm->tm_mon = ((tm->tm_mon - 1) % MONTHS_PER_YEAR) + 1;
6958 }
6959 else if (tm->tm_mon < 1)
6960 {
6961 tm->tm_year += tm->tm_mon / MONTHS_PER_YEAR - 1;
6962 tm->tm_mon = tm->tm_mon % MONTHS_PER_YEAR + MONTHS_PER_YEAR;
6963 }
6964
6965 /* adjust for end of month boundary problems... */
6966 if (tm->tm_mday > day_tab[isleap(tm->tm_year)][tm->tm_mon - 1])
6967 tm->tm_mday = (day_tab[isleap(tm->tm_year)][tm->tm_mon - 1]);
6968=====================================================================
6969Found a 54 line (161 tokens) duplication in the following files:
6970Starting at line 4605 of /home/shackle/pggit/postgresql/src/backend/commands/copy.c
6971Starting at line 4665 of /home/shackle/pggit/postgresql/src/backend/commands/copy.c
6972
6973 {
6974 start = ptr;
6975 while ((c = *ptr) != '\0')
6976 {
6977 if ((unsigned char) c < (unsigned char) 0x20)
6978 {
6979 /*
6980 * \r and \n must be escaped, the others are traditional. We
6981 * prefer to dump these using the C-like notation, rather than
6982 * a backslash and the literal character, because it makes the
6983 * dump file a bit more proof against Microsoftish data
6984 * mangling.
6985 */
6986 switch (c)
6987 {
6988 case '\b':
6989 c = 'b';
6990 break;
6991 case '\f':
6992 c = 'f';
6993 break;
6994 case '\n':
6995 c = 'n';
6996 break;
6997 case '\r':
6998 c = 'r';
6999 break;
7000 case '\t':
7001 c = 't';
7002 break;
7003 case '\v':
7004 c = 'v';
7005 break;
7006 default:
7007 /* If it's the delimiter, must backslash it */
7008 if (c == delimc)
7009 break;
7010 /* All ASCII control chars are length 1 */
7011 ptr++;
7012 continue; /* fall to end of loop */
7013 }
7014 /* if we get here, we need to convert the control char */
7015 DUMPSOFAR();
7016 CopySendChar(cstate, '\\');
7017 CopySendChar(cstate, c);
7018 start = ++ptr; /* do not include char in next run */
7019 }
7020 else if (c == '\\' || c == delimc)
7021 {
7022 DUMPSOFAR();
7023 CopySendChar(cstate, '\\');
7024 start = ptr++; /* we include char in next run */
7025 }
7026 else if (IS_HIGHBIT_SET(c))
7027=====================================================================
7028Found a 50 line (160 tokens) duplication in the following files:
7029Starting at line 4315 of /home/shackle/pggit/postgresql/src/backend/optimizer/path/indxpath.c
7030Starting at line 6489 of /home/shackle/pggit/postgresql/src/backend/utils/adt/selfuncs.c
7031
7032 if (datatype == NAMEOID)
7033 return DirectFunctionCall1(namein, CStringGetDatum(str));
7034 else if (datatype == BYTEAOID)
7035 return DirectFunctionCall1(byteain, CStringGetDatum(str));
7036 else
7037 return CStringGetTextDatum(str);
7038}
7039
7040/*
7041 * Generate a Const node of the appropriate type from a C string.
7042 */
7043static Const *
7044string_to_const(const char *str, Oid datatype)
7045{
7046 Datum conval = string_to_datum(str, datatype);
7047 Oid collation;
7048 int constlen;
7049
7050 /*
7051 * We only need to support a few datatypes here, so hard-wire properties
7052 * instead of incurring the expense of catalog lookups.
7053 */
7054 switch (datatype)
7055 {
7056 case TEXTOID:
7057 case VARCHAROID:
7058 case BPCHAROID:
7059 collation = DEFAULT_COLLATION_OID;
7060 constlen = -1;
7061 break;
7062
7063 case NAMEOID:
7064 collation = InvalidOid;
7065 constlen = NAMEDATALEN;
7066 break;
7067
7068 case BYTEAOID:
7069 collation = InvalidOid;
7070 constlen = -1;
7071 break;
7072
7073 default:
7074 elog(ERROR, "unexpected datatype in string_to_const: %u",
7075 datatype);
7076 return NULL;
7077 }
7078
7079 return makeConst(datatype, -1, collation, constlen,
7080 conval, false, false);
7081}
7082=====================================================================
7083Found a 36 line (159 tokens) duplication in the following files:
7084Starting at line 908 of /home/shackle/pggit/postgresql/src/bin/pg_ctl/pg_ctl.c
7085Starting at line 997 of /home/shackle/pggit/postgresql/src/bin/pg_ctl/pg_ctl.c
7086
7087 if (shutdown_mode == SMART_MODE &&
7088 stat(backup_file, &statbuf) == 0 &&
7089 get_control_dbstate() != DB_IN_ARCHIVE_RECOVERY)
7090 {
7091 print_msg(_("WARNING: online backup mode is active\n"
7092 "Shutdown will not complete until pg_stop_backup() is called.\n\n"));
7093 }
7094
7095 print_msg(_("waiting for server to shut down..."));
7096
7097 for (cnt = 0; cnt < wait_seconds * WAITS_PER_SEC; cnt++)
7098 {
7099 if ((pid = get_pgpid(false)) != 0)
7100 {
7101 if (cnt % WAITS_PER_SEC == 0)
7102 print_msg(".");
7103 pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
7104 }
7105 else
7106 break;
7107 }
7108
7109 if (pid != 0) /* pid file still exists */
7110 {
7111 print_msg(_(" failed\n"));
7112
7113 write_stderr(_("%s: server does not shut down\n"), progname);
7114 if (shutdown_mode == SMART_MODE)
7115 write_stderr(_("HINT: The \"-m fast\" option immediately disconnects sessions rather than\n"
7116 "waiting for session-initiated disconnection.\n"));
7117 exit(1);
7118 }
7119 print_msg(_(" done\n"));
7120
7121 print_msg(_("server stopped\n"));
7122 }
7123=====================================================================
7124Found a 31 line (159 tokens) duplication in the following files:
7125Starting at line 6568 of /home/shackle/pggit/postgresql/src/pl/plpgsql/src/pl_exec.c
7126Starting at line 6608 of /home/shackle/pggit/postgresql/src/pl/plpgsql/src/pl_exec.c
7127
7128plpgsql_param_eval_generic(ExprState *state, ExprEvalStep *op,
7129 ExprContext *econtext)
7130{
7131 ParamListInfo params;
7132 PLpgSQL_execstate *estate;
7133 int dno = op->d.cparam.paramid - 1;
7134 PLpgSQL_datum *datum;
7135 Oid datumtype;
7136 int32 datumtypmod;
7137
7138 /* fetch back the hook data */
7139 params = econtext->ecxt_param_list_info;
7140 estate = (PLpgSQL_execstate *) params->paramFetchArg;
7141 Assert(dno >= 0 && dno < estate->ndatums);
7142
7143 /* now we can access the target datum */
7144 datum = estate->datums[dno];
7145
7146 /* fetch datum's value */
7147 exec_eval_datum(estate, datum,
7148 &datumtype, &datumtypmod,
7149 op->resvalue, op->resnull);
7150
7151 /* safety check -- needed for, eg, record fields */
7152 if (unlikely(datumtype != op->d.cparam.paramtype))
7153 ereport(ERROR,
7154 (errcode(ERRCODE_DATATYPE_MISMATCH),
7155 errmsg("type of parameter %d (%s) does not match that when preparing the plan (%s)",
7156 op->d.cparam.paramid,
7157 format_type_be(datumtype),
7158 format_type_be(op->d.cparam.paramtype))));
7159=====================================================================
7160Found a 36 line (159 tokens) duplication in the following files:
7161Starting at line 1534 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-secure-openssl.c
7162Starting at line 723 of /home/shackle/pggit/postgresql/src/backend/libpq/be-secure-openssl.c
7163
7164 my_bio_methods = BIO_meth_new(my_bio_index, "libpq socket");
7165 if (!my_bio_methods)
7166 return NULL;
7167
7168 /*
7169 * As of this writing, these functions never fail. But check anyway,
7170 * like OpenSSL's own examples do.
7171 */
7172 if (!BIO_meth_set_write(my_bio_methods, my_sock_write) ||
7173 !BIO_meth_set_read(my_bio_methods, my_sock_read) ||
7174 !BIO_meth_set_gets(my_bio_methods, BIO_meth_get_gets(biom)) ||
7175 !BIO_meth_set_puts(my_bio_methods, BIO_meth_get_puts(biom)) ||
7176 !BIO_meth_set_ctrl(my_bio_methods, BIO_meth_get_ctrl(biom)) ||
7177 !BIO_meth_set_create(my_bio_methods, BIO_meth_get_create(biom)) ||
7178 !BIO_meth_set_destroy(my_bio_methods, BIO_meth_get_destroy(biom)) ||
7179 !BIO_meth_set_callback_ctrl(my_bio_methods, BIO_meth_get_callback_ctrl(biom)))
7180 {
7181 BIO_meth_free(my_bio_methods);
7182 my_bio_methods = NULL;
7183 return NULL;
7184 }
7185#else
7186 my_bio_methods = malloc(sizeof(BIO_METHOD));
7187 if (!my_bio_methods)
7188 return NULL;
7189 memcpy(my_bio_methods, biom, sizeof(BIO_METHOD));
7190 my_bio_methods->bread = my_sock_read;
7191 my_bio_methods->bwrite = my_sock_write;
7192#endif
7193 }
7194 return my_bio_methods;
7195}
7196
7197/* This should exactly match OpenSSL's SSL_set_fd except for using my BIO */
7198static int
7199my_SSL_set_fd(PGconn *conn, int fd)
7200=====================================================================
7201Found a 66 line (159 tokens) duplication in the following files:
7202Starting at line 947 of /home/shackle/pggit/postgresql/src/backend/utils/adt/float.c
7203Starting at line 1016 of /home/shackle/pggit/postgresql/src/backend/utils/adt/float.c
7204
7205 float8 base = PG_GETARG_FLOAT8(1);
7206 float8 offset = PG_GETARG_FLOAT8(2);
7207 bool sub = PG_GETARG_BOOL(3);
7208 bool less = PG_GETARG_BOOL(4);
7209 float8 sum;
7210
7211 /*
7212 * Reject negative or NaN offset. Negative is per spec, and NaN is
7213 * because appropriate semantics for that seem non-obvious.
7214 */
7215 if (isnan(offset) || offset < 0)
7216 ereport(ERROR,
7217 (errcode(ERRCODE_INVALID_PRECEDING_OR_FOLLOWING_SIZE),
7218 errmsg("invalid preceding or following size in window function")));
7219
7220 /*
7221 * Deal with cases where val and/or base is NaN, following the rule that
7222 * NaN sorts after non-NaN (cf float8_cmp_internal). The offset cannot
7223 * affect the conclusion.
7224 */
7225 if (isnan(val))
7226 {
7227 if (isnan(base))
7228 PG_RETURN_BOOL(true); /* NAN = NAN */
7229 else
7230 PG_RETURN_BOOL(!less); /* NAN > non-NAN */
7231 }
7232 else if (isnan(base))
7233 {
7234 PG_RETURN_BOOL(less); /* non-NAN < NAN */
7235 }
7236
7237 /*
7238 * Deal with infinite offset (necessarily +inf, at this point). We must
7239 * special-case this because if base happens to be -inf, their sum would
7240 * be NaN, which is an overflow-ish condition we should avoid.
7241 */
7242 if (isinf(offset))
7243 {
7244 PG_RETURN_BOOL(sub ? !less : less);
7245 }
7246
7247 /*
7248 * Otherwise it should be safe to compute base +/- offset. We trust the
7249 * FPU to cope if base is +/-inf or the true sum would overflow, and
7250 * produce a suitably signed infinity, which will compare properly against
7251 * val whether or not that's infinity.
7252 */
7253 if (sub)
7254 sum = base - offset;
7255 else
7256 sum = base + offset;
7257
7258 if (less)
7259 PG_RETURN_BOOL(val <= sum);
7260 else
7261 PG_RETURN_BOOL(val >= sum);
7262}
7263
7264/*
7265 * in_range support function for float4.
7266 *
7267 * We would need a float4_float8 variant in any case, so we supply that and
7268 * let implicit coercion take care of the float4_float4 case.
7269 */
7270Datum
7271=====================================================================
7272Found a 49 line (158 tokens) duplication in the following files:
7273Starting at line 1788 of /home/shackle/pggit/postgresql/contrib/postgres_fdw/postgres_fdw.c
7274Starting at line 1864 of /home/shackle/pggit/postgresql/contrib/postgres_fdw/postgres_fdw.c
7275Starting at line 1940 of /home/shackle/pggit/postgresql/contrib/postgres_fdw/postgres_fdw.c
7276
7277 p_values = convert_prep_stmt_params(fmstate, NULL, slot);
7278
7279 /*
7280 * Execute the prepared statement.
7281 */
7282 if (!PQsendQueryPrepared(fmstate->conn,
7283 fmstate->p_name,
7284 fmstate->p_nums,
7285 p_values,
7286 NULL,
7287 NULL,
7288 0))
7289 pgfdw_report_error(ERROR, NULL, fmstate->conn, false, fmstate->query);
7290
7291 /*
7292 * Get the result, and check for success.
7293 *
7294 * We don't use a PG_TRY block here, so be careful not to throw error
7295 * without releasing the PGresult.
7296 */
7297 res = pgfdw_get_result(fmstate->conn, fmstate->query);
7298 if (PQresultStatus(res) !=
7299 (fmstate->has_returning ? PGRES_TUPLES_OK : PGRES_COMMAND_OK))
7300 pgfdw_report_error(ERROR, res, fmstate->conn, true, fmstate->query);
7301
7302 /* Check number of rows affected, and fetch RETURNING tuple if any */
7303 if (fmstate->has_returning)
7304 {
7305 n_rows = PQntuples(res);
7306 if (n_rows > 0)
7307 store_returning_result(fmstate, slot, res);
7308 }
7309 else
7310 n_rows = atoi(PQcmdTuples(res));
7311
7312 /* And clean up */
7313 PQclear(res);
7314
7315 MemoryContextReset(fmstate->temp_cxt);
7316
7317 /* Return NULL if nothing was inserted on the remote end */
7318 return (n_rows > 0) ? slot : NULL;
7319}
7320
7321/*
7322 * postgresExecForeignUpdate
7323 * Update one row in a foreign table
7324 */
7325static TupleTableSlot *
7326=====================================================================
7327Found a 28 line (158 tokens) duplication in the following files:
7328Starting at line 204 of /home/shackle/pggit/postgresql/src/backend/commands/dbcommands.c
7329Starting at line 1423 of /home/shackle/pggit/postgresql/src/backend/commands/dbcommands.c
7330
7331 else if (strcmp(defel->defname, "is_template") == 0)
7332 {
7333 if (distemplate)
7334 ereport(ERROR,
7335 (errcode(ERRCODE_SYNTAX_ERROR),
7336 errmsg("conflicting or redundant options"),
7337 parser_errposition(pstate, defel->location)));
7338 distemplate = defel;
7339 }
7340 else if (strcmp(defel->defname, "allow_connections") == 0)
7341 {
7342 if (dallowconnections)
7343 ereport(ERROR,
7344 (errcode(ERRCODE_SYNTAX_ERROR),
7345 errmsg("conflicting or redundant options"),
7346 parser_errposition(pstate, defel->location)));
7347 dallowconnections = defel;
7348 }
7349 else if (strcmp(defel->defname, "connection_limit") == 0)
7350 {
7351 if (dconnlimit)
7352 ereport(ERROR,
7353 (errcode(ERRCODE_SYNTAX_ERROR),
7354 errmsg("conflicting or redundant options"),
7355 parser_errposition(pstate, defel->location)));
7356 dconnlimit = defel;
7357 }
7358 else if (strcmp(defel->defname, "location") == 0)
7359=====================================================================
7360Found a 22 line (157 tokens) duplication in the following files:
7361Starting at line 1275 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
7362Starting at line 1588 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
7363
7364 InitFunctionCallInfoData(fcinfo, flinfo, 7, collation, NULL, NULL);
7365
7366 fcinfo.arg[0] = arg1;
7367 fcinfo.arg[1] = arg2;
7368 fcinfo.arg[2] = arg3;
7369 fcinfo.arg[3] = arg4;
7370 fcinfo.arg[4] = arg5;
7371 fcinfo.arg[5] = arg6;
7372 fcinfo.arg[6] = arg7;
7373 fcinfo.argnull[0] = false;
7374 fcinfo.argnull[1] = false;
7375 fcinfo.argnull[2] = false;
7376 fcinfo.argnull[3] = false;
7377 fcinfo.argnull[4] = false;
7378 fcinfo.argnull[5] = false;
7379 fcinfo.argnull[6] = false;
7380
7381 result = FunctionCallInvoke(&fcinfo);
7382
7383 /* Check for null result, since caller is clearly not expecting one */
7384 if (fcinfo.isnull)
7385 elog(ERROR, "function %u returned NULL", fcinfo.flinfo->fn_oid);
7386=====================================================================
7387Found a 13 line (157 tokens) duplication in the following files:
7388Starting at line 1737 of /home/shackle/pggit/postgresql/src/backend/utils/mb/wchar.c
7389Starting at line 1753 of /home/shackle/pggit/postgresql/src/backend/utils/mb/wchar.c
7390
7391 {pg_mule2wchar_with_len, pg_wchar2mule_with_len, pg_mule_mblen, pg_mule_dsplen, pg_mule_verifier, 4}, /* PG_MULE_INTERNAL */
7392 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN1 */
7393 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN2 */
7394 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN3 */
7395 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN4 */
7396 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN5 */
7397 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN6 */
7398 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN7 */
7399 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN8 */
7400 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN9 */
7401 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN10 */
7402 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_WIN1256 */
7403 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_WIN1258 */
7404=====================================================================
7405Found a 35 line (156 tokens) duplication in the following files:
7406Starting at line 456 of /home/shackle/pggit/postgresql/contrib/hstore/hstore_gist.c
7407Starting at line 448 of /home/shackle/pggit/postgresql/contrib/intarray/_intbig_gist.c
7408
7409 if (size_alpha < size_beta + WISH_F(v->spl_nleft, v->spl_nright, 0.0001))
7410 {
7411 if (ISALLTRUE(datum_l) || ISALLTRUE(_j))
7412 {
7413 if (!ISALLTRUE(datum_l))
7414 MemSet((void *) union_l, 0xff, sizeof(BITVEC));
7415 }
7416 else
7417 {
7418 ptr = GETSIGN(_j);
7419 LOOPBYTE
7420 union_l[i] |= ptr[i];
7421 }
7422 *left++ = j;
7423 v->spl_nleft++;
7424 }
7425 else
7426 {
7427 if (ISALLTRUE(datum_r) || ISALLTRUE(_j))
7428 {
7429 if (!ISALLTRUE(datum_r))
7430 MemSet((void *) union_r, 0xff, sizeof(BITVEC));
7431 }
7432 else
7433 {
7434 ptr = GETSIGN(_j);
7435 LOOPBYTE
7436 union_r[i] |= ptr[i];
7437 }
7438 *right++ = j;
7439 v->spl_nright++;
7440 }
7441 }
7442
7443 *right = *left = FirstOffsetNumber;
7444=====================================================================
7445Found a 20 line (156 tokens) duplication in the following files:
7446Starting at line 989 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
7447Starting at line 1309 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
7448Starting at line 1625 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
7449
7450 InitFunctionCallInfoData(fcinfo, NULL, 8, collation, NULL, NULL);
7451
7452 fcinfo.arg[0] = arg1;
7453 fcinfo.arg[1] = arg2;
7454 fcinfo.arg[2] = arg3;
7455 fcinfo.arg[3] = arg4;
7456 fcinfo.arg[4] = arg5;
7457 fcinfo.arg[5] = arg6;
7458 fcinfo.arg[6] = arg7;
7459 fcinfo.arg[7] = arg8;
7460 fcinfo.argnull[0] = false;
7461 fcinfo.argnull[1] = false;
7462 fcinfo.argnull[2] = false;
7463 fcinfo.argnull[3] = false;
7464 fcinfo.argnull[4] = false;
7465 fcinfo.argnull[5] = false;
7466 fcinfo.argnull[6] = false;
7467 fcinfo.argnull[7] = false;
7468
7469 result = (*func) (&fcinfo);
7470=====================================================================
7471Found a 34 line (156 tokens) duplication in the following files:
7472Starting at line 5801 of /home/shackle/pggit/postgresql/src/backend/utils/adt/formatting.c
7473Starting at line 5904 of /home/shackle/pggit/postgresql/src/backend/utils/adt/formatting.c
7474
7475 Num.post = FLT_DIG - numstr_pre_len;
7476 orgnum = psprintf("%.*f", Num.post, val);
7477
7478 if (*orgnum == '-')
7479 { /* < 0 */
7480 sign = '-';
7481 numstr = orgnum + 1;
7482 }
7483 else
7484 {
7485 sign = '+';
7486 numstr = orgnum;
7487 }
7488
7489 if ((p = strchr(numstr, '.')))
7490 numstr_pre_len = p - numstr;
7491 else
7492 numstr_pre_len = strlen(numstr);
7493
7494 /* needs padding? */
7495 if (numstr_pre_len < Num.pre)
7496 out_pre_spaces = Num.pre - numstr_pre_len;
7497 /* overflowed prefix digit format? */
7498 else if (numstr_pre_len > Num.pre)
7499 {
7500 numstr = (char *) palloc(Num.pre + Num.post + 2);
7501 fill_str(numstr, '#', Num.pre + Num.post + 1);
7502 *(numstr + Num.pre) = '.';
7503 }
7504 }
7505
7506 NUM_TOCHAR_finish;
7507 PG_RETURN_TEXT_P(result);
7508}
7509=====================================================================
7510Found a 31 line (156 tokens) duplication in the following files:
7511Starting at line 547 of /home/shackle/pggit/postgresql/src/backend/utils/adt/pgstatfuncs.c
7512Starting at line 1100 of /home/shackle/pggit/postgresql/src/backend/replication/logical/launcher.c
7513
7514 int pid = PG_ARGISNULL(0) ? -1 : PG_GETARG_INT32(0);
7515 ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo;
7516 TupleDesc tupdesc;
7517 Tuplestorestate *tupstore;
7518 MemoryContext per_query_ctx;
7519 MemoryContext oldcontext;
7520
7521 /* check to see if caller supports us returning a tuplestore */
7522 if (rsinfo == NULL || !IsA(rsinfo, ReturnSetInfo))
7523 ereport(ERROR,
7524 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
7525 errmsg("set-valued function called in context that cannot accept a set")));
7526 if (!(rsinfo->allowedModes & SFRM_Materialize))
7527 ereport(ERROR,
7528 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
7529 errmsg("materialize mode required, but it is not " \
7530 "allowed in this context")));
7531
7532 /* Build a tuple descriptor for our result type */
7533 if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
7534 elog(ERROR, "return type must be a row type");
7535
7536 per_query_ctx = rsinfo->econtext->ecxt_per_query_memory;
7537 oldcontext = MemoryContextSwitchTo(per_query_ctx);
7538
7539 tupstore = tuplestore_begin_heap(true, false, work_mem);
7540 rsinfo->returnMode = SFRM_Materialize;
7541 rsinfo->setResult = tupstore;
7542 rsinfo->setDesc = tupdesc;
7543
7544 MemoryContextSwitchTo(oldcontext);
7545=====================================================================
7546Found a 33 line (155 tokens) duplication in the following files:
7547Starting at line 951 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/ecpglib/execute.c
7548Starting at line 998 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/ecpglib/execute.c
7549
7550 str = quote_postgres(PGTYPESdate_to_asc(((date *) (var->value))[element]), quote, lineno);
7551 if (!str)
7552 {
7553 ecpg_free(mallocedval);
7554 return false;
7555 }
7556
7557 slen = strlen(str);
7558
7559 if (!(newcopy = ecpg_realloc(mallocedval, strlen(mallocedval) + slen + 2, lineno)))
7560 {
7561 ecpg_free(mallocedval);
7562 ecpg_free(str);
7563 return false;
7564 }
7565 mallocedval = newcopy;
7566
7567 /* also copy trailing '\0' */
7568 memcpy(mallocedval + strlen(mallocedval), str, slen + 1);
7569 if (var->arrsize > 1)
7570 strcpy(mallocedval + strlen(mallocedval), ",");
7571
7572 ecpg_free(str);
7573 }
7574
7575 if (var->arrsize > 1)
7576 strcpy(mallocedval + strlen(mallocedval) - 1, "}");
7577
7578 *tobeinserted_p = mallocedval;
7579 }
7580 break;
7581
7582 case ECPGt_timestamp:
7583=====================================================================
7584Found a 46 line (155 tokens) duplication in the following files:
7585Starting at line 113 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/interval.c
7586Starting at line 3508 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
7587
7588 int *dtype, struct /* pg_ */ tm *tm, fsec_t *fsec)
7589{
7590 bool datepart = true;
7591 bool havefield = false;
7592
7593 *dtype = DTK_DELTA;
7594 ClearPgTm(tm, fsec);
7595
7596 if (strlen(str) < 2 || str[0] != 'P')
7597 return DTERR_BAD_FORMAT;
7598
7599 str++;
7600 while (*str)
7601 {
7602 char *fieldstart;
7603 int val;
7604 double fval;
7605 char unit;
7606 int dterr;
7607
7608 if (*str == 'T') /* T indicates the beginning of the time part */
7609 {
7610 datepart = false;
7611 havefield = false;
7612 str++;
7613 continue;
7614 }
7615
7616 fieldstart = str;
7617 dterr = ParseISO8601Number(str, &str, &val, &fval);
7618 if (dterr)
7619 return dterr;
7620
7621 /*
7622 * Note: we could step off the end of the string here. Code below
7623 * *must* exit the loop if unit == '\0'.
7624 */
7625 unit = *str++;
7626
7627 if (datepart)
7628 {
7629 switch (unit) /* before T: Y M W D */
7630 {
7631 case 'Y':
7632 tm->tm_year += val;
7633 tm->tm_mon += (fval * 12);
7634=====================================================================
7635Found a 32 line (155 tokens) duplication in the following files:
7636Starting at line 5739 of /home/shackle/pggit/postgresql/src/backend/utils/adt/formatting.c
7637Starting at line 5843 of /home/shackle/pggit/postgresql/src/backend/utils/adt/formatting.c
7638
7639 float4 value = PG_GETARG_FLOAT4(0);
7640 text *fmt = PG_GETARG_TEXT_PP(1);
7641 NUMDesc Num;
7642 FormatNode *format;
7643 text *result;
7644 bool shouldFree;
7645 int out_pre_spaces = 0,
7646 sign = 0;
7647 char *numstr,
7648 *orgnum,
7649 *p;
7650
7651 NUM_TOCHAR_prepare;
7652
7653 if (IS_ROMAN(&Num))
7654 numstr = orgnum = int_to_roman((int) rint(value));
7655 else if (IS_EEEE(&Num))
7656 {
7657 if (isnan(value) || isinf(value))
7658 {
7659 /*
7660 * Allow 6 characters for the leading sign, the decimal point,
7661 * "e", the exponent's sign and two exponent digits.
7662 */
7663 numstr = (char *) palloc(Num.pre + Num.post + 7);
7664 fill_str(numstr, '#', Num.pre + Num.post + 6);
7665 *numstr = ' ';
7666 *(numstr + Num.pre + 1) = '.';
7667 }
7668 else
7669 {
7670 numstr = orgnum = psprintf("%+.*e", Num.post, value);
7671=====================================================================
7672Found a 45 line (154 tokens) duplication in the following files:
7673Starting at line 2172 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/dt_common.c
7674Starting at line 1225 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
7675
7676 tm->tm_sec = 0;
7677 break;
7678
7679 case DTK_ZULU:
7680 tmask = (DTK_TIME_M | DTK_M(TZ));
7681 *dtype = DTK_DATE;
7682 tm->tm_hour = 0;
7683 tm->tm_min = 0;
7684 tm->tm_sec = 0;
7685 if (tzp != NULL)
7686 *tzp = 0;
7687 break;
7688
7689 default:
7690 *dtype = val;
7691 }
7692
7693 break;
7694
7695 case MONTH:
7696
7697 /*
7698 * already have a (numeric) month? then see if we can
7699 * substitute...
7700 */
7701 if ((fmask & DTK_M(MONTH)) && !haveTextMonth &&
7702 !(fmask & DTK_M(DAY)) && tm->tm_mon >= 1 && tm->tm_mon <= 31)
7703 {
7704 tm->tm_mday = tm->tm_mon;
7705 tmask = DTK_M(DAY);
7706 }
7707 haveTextMonth = true;
7708 tm->tm_mon = val;
7709 break;
7710
7711 case DTZMOD:
7712
7713 /*
7714 * daylight savings time modifier (solves "MET DST"
7715 * syntax)
7716 */
7717 tmask |= DTK_M(DTZ);
7718 tm->tm_isdst = 1;
7719 if (tzp == NULL)
7720 return -1;
7721=====================================================================
7722Found a 16 line (154 tokens) duplication in the following files:
7723Starting at line 216 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
7724Starting at line 356 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
7725Starting at line 524 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
7726
7727 ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
7728 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
7729 ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
7730 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
7731 ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
7732 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
7733#line 74 "cursor.pgc"
7734
7735if (sqlca.sqlcode < 0) exit (1);}
7736#line 74 "cursor.pgc"
7737
7738 printf("%d %s\n", id, t);
7739
7740 strcpy(msg, "fetch 1 from");
7741 { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch 1 from $0",
7742 ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
7743=====================================================================
7744Found a 16 line (154 tokens) duplication in the following files:
7745Starting at line 292 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
7746Starting at line 436 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
7747Starting at line 600 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
7748
7749 ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
7750 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
7751 ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
7752 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
7753 ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
7754 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
7755#line 95 "cursor.pgc"
7756
7757if (sqlca.sqlcode < 0) exit (1);}
7758#line 95 "cursor.pgc"
7759
7760 printf("%d %s\n", id, t);
7761
7762 strcpy(msg, "close");
7763 { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "close $0",
7764 ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
7765=====================================================================
7766Found a 16 line (154 tokens) duplication in the following files:
7767Starting at line 389 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
7768Starting at line 557 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
7769
7770 ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
7771 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
7772 ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
7773 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
7774 ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
7775 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
7776#line 124 "cursor.pgc"
7777
7778if (sqlca.sqlcode < 0) exit (1);}
7779#line 124 "cursor.pgc"
7780
7781 printf("%d %s\n", id, t);
7782
7783 strcpy(msg, "move");
7784 { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "move absolute 0 $0",
7785 ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
7786=====================================================================
7787Found a 19 line (154 tokens) duplication in the following files:
7788Starting at line 420 of /home/shackle/pggit/postgresql/src/backend/nodes/outfuncs.c
7789Starting at line 511 of /home/shackle/pggit/postgresql/src/backend/nodes/outfuncs.c
7790Starting at line 891 of /home/shackle/pggit/postgresql/src/backend/nodes/outfuncs.c
7791
7792 WRITE_NODE_FIELD(mergeplans);
7793
7794 WRITE_INT_FIELD(numCols);
7795
7796 appendStringInfoString(str, " :sortColIdx");
7797 for (i = 0; i < node->numCols; i++)
7798 appendStringInfo(str, " %d", node->sortColIdx[i]);
7799
7800 appendStringInfoString(str, " :sortOperators");
7801 for (i = 0; i < node->numCols; i++)
7802 appendStringInfo(str, " %u", node->sortOperators[i]);
7803
7804 appendStringInfoString(str, " :collations");
7805 for (i = 0; i < node->numCols; i++)
7806 appendStringInfo(str, " %u", node->collations[i]);
7807
7808 appendStringInfoString(str, " :nullsFirst");
7809 for (i = 0; i < node->numCols; i++)
7810 appendStringInfo(str, " %s", booltostr(node->nullsFirst[i]));
7811=====================================================================
7812Found a 24 line (154 tokens) duplication in the following files:
7813Starting at line 389 of /home/shackle/pggit/postgresql/src/backend/tsearch/wparser.c
7814Starting at line 465 of /home/shackle/pggit/postgresql/src/backend/tsearch/wparser.c
7815
7816 Jsonb *out;
7817 JsonTransformStringValuesAction action = (JsonTransformStringValuesAction) headline_json_value;
7818 HeadlineParsedText prs;
7819 HeadlineJsonState *state = palloc0(sizeof(HeadlineJsonState));
7820
7821 memset(&prs, 0, sizeof(HeadlineParsedText));
7822 prs.lenwords = 32;
7823 prs.words = (HeadlineWordEntry *) palloc(sizeof(HeadlineWordEntry) * prs.lenwords);
7824
7825 state->prs = &prs;
7826 state->cfg = lookup_ts_config_cache(tsconfig);
7827 state->prsobj = lookup_ts_parser_cache(state->cfg->prsId);
7828 state->query = query;
7829 if (opt)
7830 state->prsoptions = deserialize_deflist(PointerGetDatum(opt));
7831 else
7832 state->prsoptions = NIL;
7833
7834 if (!OidIsValid(state->prsobj->headlineOid))
7835 ereport(ERROR,
7836 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
7837 errmsg("text search parser does not support headline creation")));
7838
7839 out = transform_jsonb_string_values(jb, state, action);
7840=====================================================================
7841Found a 47 line (153 tokens) duplication in the following files:
7842Starting at line 130 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/compat_informix-describe.c
7843Starting at line 128 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-describe.c
7844
7845 { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into descr_t1 ( id , t ) values ( default , 'd' )", ECPGt_EOIT, ECPGt_EORT);
7846#line 39 "describe.pgc"
7847
7848if (sqlca.sqlcode < 0) exit (1);}
7849#line 39 "describe.pgc"
7850
7851
7852 strcpy(msg, "commit");
7853 { ECPGtrans(__LINE__, NULL, "commit");
7854#line 42 "describe.pgc"
7855
7856if (sqlca.sqlcode < 0) exit (1);}
7857#line 42 "describe.pgc"
7858
7859
7860 /*
7861 * Test DESCRIBE with a query producing tuples.
7862 * DESCRIPTOR and SQL DESCRIPTOR are NOT the same in
7863 * Informix-compat mode.
7864 */
7865
7866 strcpy(msg, "allocate");
7867 ECPGallocate_desc(__LINE__, "desc1");
7868#line 51 "describe.pgc"
7869
7870if (sqlca.sqlcode < 0) exit (1);
7871#line 51 "describe.pgc"
7872
7873 ECPGallocate_desc(__LINE__, "desc2");
7874#line 52 "describe.pgc"
7875
7876if (sqlca.sqlcode < 0) exit (1);
7877#line 52 "describe.pgc"
7878
7879
7880 strcpy(msg, "prepare");
7881 { ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1);
7882#line 55 "describe.pgc"
7883
7884if (sqlca.sqlcode < 0) exit (1);}
7885#line 55 "describe.pgc"
7886
7887
7888 sqlda1 = sqlda2 = sqlda3 = NULL;
7889
7890 strcpy(msg, "describe");
7891 { ECPGdescribe(__LINE__, 1, 0, NULL, "st_id1",
7892=====================================================================
7893Found a 27 line (152 tokens) duplication in the following files:
7894Starting at line 489 of /home/shackle/pggit/postgresql/contrib/ltree/ltxtquery_io.c
7895Starting at line 614 of /home/shackle/pggit/postgresql/contrib/intarray/_int_bool.c
7896
7897 nrm.op = in->op;
7898 nrm.buflen = 16;
7899 nrm.cur = nrm.buf = (char *) palloc(sizeof(char) * nrm.buflen);
7900
7901 /* get right operand */
7902 infix(&nrm, false);
7903
7904 /* get & print left operand */
7905 in->curpol = nrm.curpol;
7906 infix(in, false);
7907
7908 /* print operator & right operand */
7909 RESIZEBUF(in, 3 + (nrm.cur - nrm.buf));
7910 sprintf(in->cur, " %c %s", op, nrm.buf);
7911 in->cur = strchr(in->cur, '\0');
7912 pfree(nrm.buf);
7913
7914 if (op == (int32) '|' && !first)
7915 {
7916 RESIZEBUF(in, 2);
7917 sprintf(in->cur, " )");
7918 in->cur = strchr(in->cur, '\0');
7919 }
7920 }
7921}
7922
7923Datum
7924=====================================================================
7925Found a 37 line (152 tokens) duplication in the following files:
7926Starting at line 580 of /home/shackle/pggit/postgresql/contrib/pg_trgm/trgm_gist.c
7927Starting at line 449 of /home/shackle/pggit/postgresql/src/backend/utils/adt/tsgistidx.c
7928
7929 TRGM *b = (TRGM *) PG_GETARG_POINTER(1);
7930 bool *result = (bool *) PG_GETARG_POINTER(2);
7931
7932 if (ISSIGNKEY(a))
7933 { /* then b also ISSIGNKEY */
7934 if (ISALLTRUE(a) && ISALLTRUE(b))
7935 *result = true;
7936 else if (ISALLTRUE(a))
7937 *result = false;
7938 else if (ISALLTRUE(b))
7939 *result = false;
7940 else
7941 {
7942 int32 i;
7943 BITVECP sa = GETSIGN(a),
7944 sb = GETSIGN(b);
7945
7946 *result = true;
7947 LOOPBYTE
7948 {
7949 if (sa[i] != sb[i])
7950 {
7951 *result = false;
7952 break;
7953 }
7954 }
7955 }
7956 }
7957 else
7958 { /* a and b ISARRKEY */
7959 int32 lena = ARRNELEM(a),
7960 lenb = ARRNELEM(b);
7961
7962 if (lena != lenb)
7963 *result = false;
7964 else
7965 {
7966=====================================================================
7967Found a 36 line (151 tokens) duplication in the following files:
7968Starting at line 2798 of /home/shackle/pggit/postgresql/src/pl/plpgsql/src/pl_exec.c
7969Starting at line 4563 of /home/shackle/pggit/postgresql/src/pl/plpgsql/src/pl_exec.c
7970
7971 if (stmt->argquery != NULL)
7972 {
7973 /* ----------
7974 * OPEN CURSOR with args. We fake a SELECT ... INTO ...
7975 * statement to evaluate the args and put 'em into the
7976 * internal row.
7977 * ----------
7978 */
7979 PLpgSQL_stmt_execsql set_args;
7980
7981 if (curvar->cursor_explicit_argrow < 0)
7982 ereport(ERROR,
7983 (errcode(ERRCODE_SYNTAX_ERROR),
7984 errmsg("arguments given for cursor without arguments")));
7985
7986 memset(&set_args, 0, sizeof(set_args));
7987 set_args.cmd_type = PLPGSQL_STMT_EXECSQL;
7988 set_args.lineno = stmt->lineno;
7989 set_args.sqlstmt = stmt->argquery;
7990 set_args.into = true;
7991 /* XXX historically this has not been STRICT */
7992 set_args.target = (PLpgSQL_variable *)
7993 (estate->datums[curvar->cursor_explicit_argrow]);
7994
7995 if (exec_stmt_execsql(estate, &set_args) != PLPGSQL_RC_OK)
7996 elog(ERROR, "open cursor failed during argument processing");
7997 }
7998 else
7999 {
8000 if (curvar->cursor_explicit_argrow >= 0)
8001 ereport(ERROR,
8002 (errcode(ERRCODE_SYNTAX_ERROR),
8003 errmsg("arguments required for cursor")));
8004 }
8005
8006 query = curvar->cursor_explicit_expr;
8007=====================================================================
8008Found a 38 line (151 tokens) duplication in the following files:
8009Starting at line 244 of /home/shackle/pggit/postgresql/src/test/examples/testlo64.c
8010Starting at line 220 of /home/shackle/pggit/postgresql/src/test/examples/testlo.c
8011
8012 out_filename2 = argv[4];
8013
8014 /*
8015 * set up the connection
8016 */
8017 conn = PQsetdb(NULL, NULL, NULL, NULL, database);
8018
8019 /* check to see that the backend connection was successfully made */
8020 if (PQstatus(conn) != CONNECTION_OK)
8021 {
8022 fprintf(stderr, "Connection to database failed: %s",
8023 PQerrorMessage(conn));
8024 exit_nicely(conn);
8025 }
8026
8027 /* Set always-secure search path, so malicious users can't take control. */
8028 res = PQexec(conn,
8029 "SELECT pg_catalog.set_config('search_path', '', false)");
8030 if (PQresultStatus(res) != PGRES_TUPLES_OK)
8031 {
8032 fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
8033 PQclear(res);
8034 exit_nicely(conn);
8035 }
8036 PQclear(res);
8037
8038 res = PQexec(conn, "begin");
8039 PQclear(res);
8040 printf("importing file \"%s\" ...\n", in_filename);
8041/* lobjOid = importFile(conn, in_filename); */
8042 lobjOid = lo_import(conn, in_filename);
8043 if (lobjOid == 0)
8044 fprintf(stderr, "%s\n", PQerrorMessage(conn));
8045 else
8046 {
8047 printf("\tas large object %u.\n", lobjOid);
8048
8049 printf("picking out bytes 4294967000-4294968000 of the large object\n");
8050=====================================================================
8051Found a 33 line (151 tokens) duplication in the following files:
8052Starting at line 942 of /home/shackle/pggit/postgresql/src/backend/utils/sort/tuplesort.c
8053Starting at line 1020 of /home/shackle/pggit/postgresql/src/backend/utils/sort/tuplesort.c
8054
8055 state->sortKeys = (SortSupport) palloc0(state->nKeys *
8056 sizeof(SortSupportData));
8057
8058 for (i = 0; i < state->nKeys; i++)
8059 {
8060 SortSupport sortKey = state->sortKeys + i;
8061 ScanKey scanKey = indexScanKey + i;
8062 int16 strategy;
8063
8064 sortKey->ssup_cxt = CurrentMemoryContext;
8065 sortKey->ssup_collation = scanKey->sk_collation;
8066 sortKey->ssup_nulls_first =
8067 (scanKey->sk_flags & SK_BT_NULLS_FIRST) != 0;
8068 sortKey->ssup_attno = scanKey->sk_attno;
8069 /* Convey if abbreviation optimization is applicable in principle */
8070 sortKey->abbreviate = (i == 0);
8071
8072 AssertState(sortKey->ssup_attno != 0);
8073
8074 strategy = (scanKey->sk_flags & SK_BT_DESC) != 0 ?
8075 BTGreaterStrategyNumber : BTLessStrategyNumber;
8076
8077 PrepareSortSupportFromIndexRel(indexRel, strategy, sortKey);
8078 }
8079
8080 _bt_freeskey(indexScanKey);
8081
8082 MemoryContextSwitchTo(oldcontext);
8083
8084 return state;
8085}
8086
8087Tuplesortstate *
8088=====================================================================
8089Found a 25 line (151 tokens) duplication in the following files:
8090Starting at line 218 of /home/shackle/pggit/postgresql/src/backend/access/rmgrdesc/xactdesc.c
8091Starting at line 269 of /home/shackle/pggit/postgresql/src/backend/access/rmgrdesc/xactdesc.c
8092
8093 ParseCommitRecord(info, xlrec, &parsed);
8094
8095 /* If this is a prepared xact, show the xid of the original xact */
8096 if (TransactionIdIsValid(parsed.twophase_xid))
8097 appendStringInfo(buf, "%u: ", parsed.twophase_xid);
8098
8099 appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time));
8100
8101 if (parsed.nrels > 0)
8102 {
8103 appendStringInfoString(buf, "; rels:");
8104 for (i = 0; i < parsed.nrels; i++)
8105 {
8106 char *path = relpathperm(parsed.xnodes[i], MAIN_FORKNUM);
8107
8108 appendStringInfo(buf, " %s", path);
8109 pfree(path);
8110 }
8111 }
8112 if (parsed.nsubxacts > 0)
8113 {
8114 appendStringInfoString(buf, "; subxacts:");
8115 for (i = 0; i < parsed.nsubxacts; i++)
8116 appendStringInfo(buf, " %u", parsed.subxacts[i]);
8117 }
8118=====================================================================
8119Found a 38 line (150 tokens) duplication in the following files:
8120Starting at line 2874 of /home/shackle/pggit/postgresql/src/backend/catalog/objectaddress.c
8121Starting at line 4428 of /home/shackle/pggit/postgresql/src/backend/catalog/objectaddress.c
8122
8123 NameStr(conv->conname)));
8124 ReleaseSysCache(conTup);
8125 break;
8126 }
8127
8128 case OCLASS_DEFAULT:
8129 {
8130 Relation attrdefDesc;
8131 ScanKeyData skey[1];
8132 SysScanDesc adscan;
8133 HeapTuple tup;
8134 Form_pg_attrdef attrdef;
8135 ObjectAddress colobject;
8136
8137 attrdefDesc = heap_open(AttrDefaultRelationId, AccessShareLock);
8138
8139 ScanKeyInit(&skey[0],
8140 Anum_pg_attrdef_oid,
8141 BTEqualStrategyNumber, F_OIDEQ,
8142 ObjectIdGetDatum(object->objectId));
8143
8144 adscan = systable_beginscan(attrdefDesc, AttrDefaultOidIndexId,
8145 true, NULL, 1, skey);
8146
8147 tup = systable_getnext(adscan);
8148
8149 if (!HeapTupleIsValid(tup))
8150 elog(ERROR, "could not find tuple for attrdef %u",
8151 object->objectId);
8152
8153 attrdef = (Form_pg_attrdef) GETSTRUCT(tup);
8154
8155 colobject.classId = RelationRelationId;
8156 colobject.objectId = attrdef->adrelid;
8157 colobject.objectSubId = attrdef->adnum;
8158
8159 /* translator: %s is typically "column %s of table %s" */
8160 appendStringInfo(&buffer, _("default value for %s"),
8161=====================================================================
8162Found a 37 line (150 tokens) duplication in the following files:
8163Starting at line 2028 of /home/shackle/pggit/postgresql/src/backend/utils/adt/selfuncs.c
8164Starting at line 2095 of /home/shackle/pggit/postgresql/src/backend/utils/adt/selfuncs.c
8165
8166 elmbyval));
8167 if (is_join_clause)
8168 s2 = DatumGetFloat8(FunctionCall5Coll(&oprselproc,
8169 clause->inputcollid,
8170 PointerGetDatum(root),
8171 ObjectIdGetDatum(operator),
8172 PointerGetDatum(args),
8173 Int16GetDatum(jointype),
8174 PointerGetDatum(sjinfo)));
8175 else
8176 s2 = DatumGetFloat8(FunctionCall4Coll(&oprselproc,
8177 clause->inputcollid,
8178 PointerGetDatum(root),
8179 ObjectIdGetDatum(operator),
8180 PointerGetDatum(args),
8181 Int32GetDatum(varRelid)));
8182
8183 if (useOr)
8184 {
8185 s1 = s1 + s2 - s1 * s2;
8186 if (isEquality)
8187 s1disjoint += s2;
8188 }
8189 else
8190 {
8191 s1 = s1 * s2;
8192 if (isInequality)
8193 s1disjoint += s2 - 1.0;
8194 }
8195 }
8196
8197 /* accept disjoint-probability estimate if in range */
8198 if ((useOr ? isEquality : isInequality) &&
8199 s1disjoint >= 0.0 && s1disjoint <= 1.0)
8200 s1 = s1disjoint;
8201 }
8202 else if (rightop && IsA(rightop, ArrayExpr) &&
8203=====================================================================
8204Found a 35 line (150 tokens) duplication in the following files:
8205Starting at line 380 of /home/shackle/pggit/postgresql/src/backend/utils/adt/arrayfuncs.c
8206Starting at line 1384 of /home/shackle/pggit/postgresql/src/backend/utils/adt/arrayfuncs.c
8207
8208 typdelim,
8209 typlen, typbyval, typalign,
8210 dataPtr, nullsPtr,
8211 &hasnulls, &nbytes);
8212 if (hasnulls)
8213 {
8214 dataoffset = ARR_OVERHEAD_WITHNULLS(ndim, nitems);
8215 nbytes += dataoffset;
8216 }
8217 else
8218 {
8219 dataoffset = 0; /* marker for no null bitmap */
8220 nbytes += ARR_OVERHEAD_NONULLS(ndim);
8221 }
8222 retval = (ArrayType *) palloc0(nbytes);
8223 SET_VARSIZE(retval, nbytes);
8224 retval->ndim = ndim;
8225 retval->dataoffset = dataoffset;
8226
8227 /*
8228 * This comes from the array's pg_type.typelem (which points to the base
8229 * data type's pg_type.oid) and stores system oids in user tables. This
8230 * oid must be preserved by binary upgrades.
8231 */
8232 retval->elemtype = element_type;
8233 memcpy(ARR_DIMS(retval), dim, ndim * sizeof(int));
8234 memcpy(ARR_LBOUND(retval), lBound, ndim * sizeof(int));
8235
8236 CopyArrayEls(retval,
8237 dataPtr, nullsPtr, nitems,
8238 typlen, typbyval, typalign,
8239 true);
8240
8241 pfree(dataPtr);
8242 pfree(nullsPtr);
8243=====================================================================
8244Found a 30 line (149 tokens) duplication in the following files:
8245Starting at line 2681 of /home/shackle/pggit/postgresql/src/backend/executor/spi.c
8246Starting at line 2745 of /home/shackle/pggit/postgresql/src/backend/executor/spi.c
8247
8248 plancxt = AllocSetContextCreate(parentcxt,
8249 "SPI Plan",
8250 ALLOCSET_SMALL_SIZES);
8251 oldcxt = MemoryContextSwitchTo(plancxt);
8252
8253 /* Copy the SPI_plan struct and subsidiary data into the new context */
8254 newplan = (SPIPlanPtr) palloc0(sizeof(_SPI_plan));
8255 newplan->magic = _SPI_PLAN_MAGIC;
8256 newplan->plancxt = plancxt;
8257 newplan->cursor_options = plan->cursor_options;
8258 newplan->nargs = plan->nargs;
8259 if (plan->nargs > 0)
8260 {
8261 newplan->argtypes = (Oid *) palloc(plan->nargs * sizeof(Oid));
8262 memcpy(newplan->argtypes, plan->argtypes, plan->nargs * sizeof(Oid));
8263 }
8264 else
8265 newplan->argtypes = NULL;
8266 newplan->parserSetup = plan->parserSetup;
8267 newplan->parserSetupArg = plan->parserSetupArg;
8268
8269 /*
8270 * Reparent all the CachedPlanSources into the procedure context. In
8271 * theory this could fail partway through due to the pallocs, but we don't
8272 * care too much since both the procedure context and the executor context
8273 * would go away on error.
8274 */
8275 foreach(lc, plan->plancache_list)
8276 {
8277 CachedPlanSource *plansource = (CachedPlanSource *) lfirst(lc);
8278=====================================================================
8279Found a 34 line (149 tokens) duplication in the following files:
8280Starting at line 531 of /home/shackle/pggit/postgresql/src/backend/libpq/be-secure-openssl.c
8281Starting at line 590 of /home/shackle/pggit/postgresql/src/backend/libpq/be-secure-openssl.c
8282
8283 n = SSL_read(port->ssl, ptr, len);
8284 err = SSL_get_error(port->ssl, n);
8285 ecode = (err != SSL_ERROR_NONE || n < 0) ? ERR_get_error() : 0;
8286 switch (err)
8287 {
8288 case SSL_ERROR_NONE:
8289 /* a-ok */
8290 break;
8291 case SSL_ERROR_WANT_READ:
8292 *waitfor = WL_SOCKET_READABLE;
8293 errno = EWOULDBLOCK;
8294 n = -1;
8295 break;
8296 case SSL_ERROR_WANT_WRITE:
8297 *waitfor = WL_SOCKET_WRITEABLE;
8298 errno = EWOULDBLOCK;
8299 n = -1;
8300 break;
8301 case SSL_ERROR_SYSCALL:
8302 /* leave it to caller to ereport the value of errno */
8303 if (n != -1)
8304 {
8305 errno = ECONNRESET;
8306 n = -1;
8307 }
8308 break;
8309 case SSL_ERROR_SSL:
8310 ereport(COMMERROR,
8311 (errcode(ERRCODE_PROTOCOL_VIOLATION),
8312 errmsg("SSL error: %s", SSLerrmessage(ecode))));
8313 errno = ECONNRESET;
8314 n = -1;
8315 break;
8316 case SSL_ERROR_ZERO_RETURN:
8317=====================================================================
8318Found a 32 line (149 tokens) duplication in the following files:
8319Starting at line 1040 of /home/shackle/pggit/postgresql/src/backend/utils/adt/arrayfuncs.c
8320Starting at line 4568 of /home/shackle/pggit/postgresql/src/backend/utils/adt/varlena.c
8321
8322 ArrayMetaState *my_extra;
8323
8324 /*
8325 * We arrange to look up info about element type, including its output
8326 * conversion proc, only once per series of calls, assuming the element
8327 * type doesn't change underneath us.
8328 */
8329 my_extra = (ArrayMetaState *) fcinfo->flinfo->fn_extra;
8330 if (my_extra == NULL)
8331 {
8332 fcinfo->flinfo->fn_extra = MemoryContextAlloc(fcinfo->flinfo->fn_mcxt,
8333 sizeof(ArrayMetaState));
8334 my_extra = (ArrayMetaState *) fcinfo->flinfo->fn_extra;
8335 my_extra->element_type = ~element_type;
8336 }
8337
8338 if (my_extra->element_type != element_type)
8339 {
8340 /*
8341 * Get info about element type, including its output conversion proc
8342 */
8343 get_type_io_data(element_type, IOFunc_output,
8344 &my_extra->typlen, &my_extra->typbyval,
8345 &my_extra->typalign, &my_extra->typdelim,
8346 &my_extra->typioparam, &my_extra->typiofunc);
8347 fmgr_info_cxt(my_extra->typiofunc, &my_extra->proc,
8348 fcinfo->flinfo->fn_mcxt);
8349 my_extra->element_type = element_type;
8350 }
8351 typlen = my_extra->typlen;
8352 typbyval = my_extra->typbyval;
8353 typalign = my_extra->typalign;
8354=====================================================================
8355Found a 30 line (149 tokens) duplication in the following files:
8356Starting at line 523 of /home/shackle/pggit/postgresql/src/backend/commands/opclasscmds.c
8357Starting at line 902 of /home/shackle/pggit/postgresql/src/backend/commands/opclasscmds.c
8358
8359 assignOperTypes(member, amoid, typeoid);
8360 addFamilyMember(&operators, member, false);
8361 break;
8362 case OPCLASS_ITEM_FUNCTION:
8363 if (item->number <= 0 || item->number > maxProcNumber)
8364 ereport(ERROR,
8365 (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
8366 errmsg("invalid function number %d,"
8367 " must be between 1 and %d",
8368 item->number, maxProcNumber)));
8369 funcOid = LookupFuncWithArgs(OBJECT_FUNCTION, item->name, false);
8370#ifdef NOT_USED
8371 /* XXX this is unnecessary given the superuser check above */
8372 /* Caller must own function */
8373 if (!pg_proc_ownercheck(funcOid, GetUserId()))
8374 aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_FUNCTION,
8375 get_func_name(funcOid));
8376#endif
8377
8378 /* Save the info */
8379 member = (OpFamilyMember *) palloc0(sizeof(OpFamilyMember));
8380 member->object = funcOid;
8381 member->number = item->number;
8382
8383 /* allow overriding of the function's actual arg types */
8384 if (item->class_args)
8385 processTypesSpec(item->class_args,
8386 &member->lefttype, &member->righttype);
8387
8388 assignProcTypes(member, amoid, typeoid);
8389=====================================================================
8390Found a 27 line (148 tokens) duplication in the following files:
8391Starting at line 430 of /home/shackle/pggit/postgresql/contrib/hstore/hstore_gist.c
8392Starting at line 422 of /home/shackle/pggit/postgresql/contrib/intarray/_intbig_gist.c
8393
8394 costvector[j - 1].cost = abs(size_alpha - size_beta);
8395 }
8396 qsort((void *) costvector, maxoff, sizeof(SPLITCOST), comparecost);
8397
8398 union_l = GETSIGN(datum_l);
8399 union_r = GETSIGN(datum_r);
8400
8401 for (k = 0; k < maxoff; k++)
8402 {
8403 j = costvector[k].pos;
8404 if (j == seed_1)
8405 {
8406 *left++ = j;
8407 v->spl_nleft++;
8408 continue;
8409 }
8410 else if (j == seed_2)
8411 {
8412 *right++ = j;
8413 v->spl_nright++;
8414 continue;
8415 }
8416 _j = GETENTRY(entryvec, j);
8417 size_alpha = hemdist(datum_l, _j);
8418 size_beta = hemdist(datum_r, _j);
8419
8420 if (size_alpha < size_beta + WISH_F(v->spl_nleft, v->spl_nright, 0.0001))
8421=====================================================================
8422Found a 16 line (148 tokens) duplication in the following files:
8423Starting at line 203 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-array.c
8424Starting at line 243 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-array.c
8425
8426 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test ( f , i , a , text , ts , n , d , inter ) values ( 404.90 , 3 , '{0,1,2,3,4,5,6,7,8,9}' , 'abcdefghij' , $1 , $2 , $3 , $4 )",
8427 ECPGt_timestamp,&(ts),(long)1,(long)10,sizeof(timestamp),
8428 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
8429 ECPGt_numeric,&(n),(long)1,(long)10,sizeof(numeric),
8430 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
8431 ECPGt_date,&(d),(long)1,(long)10,sizeof(date),
8432 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
8433 ECPGt_interval,&(in),(long)1,(long)10,sizeof(interval),
8434 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
8435#line 61 "array.pgc"
8436
8437if (sqlca.sqlcode < 0) sqlprint();}
8438#line 61 "array.pgc"
8439
8440
8441 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test ( f , i , a , text , ts , n , d , inter ) values ( 140787.0 , 2 , $1 , $2 , $3 , $4 , $5 , $6 )",
8442=====================================================================
8443Found a 15 line (148 tokens) duplication in the following files:
8444Starting at line 201 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
8445Starting at line 341 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
8446
8447 ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
8448 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
8449 ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
8450 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
8451 ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
8452 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
8453#line 70 "cursor.pgc"
8454
8455if (sqlca.sqlcode < 0) exit (1);}
8456#line 70 "cursor.pgc"
8457
8458 printf("%d %s\n", id, t);
8459
8460 strcpy(msg, "fetch");
8461 { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch forward $0",
8462=====================================================================
8463Found a 34 line (148 tokens) duplication in the following files:
8464Starting at line 3329 of /home/shackle/pggit/postgresql/src/backend/optimizer/plan/createplan.c
8465Starting at line 2431 of /home/shackle/pggit/postgresql/src/backend/optimizer/path/allpaths.c
8466
8467 Assert(!rte->self_reference);
8468
8469 /*
8470 * Find the referenced CTE, and locate the SubPlan previously made for it.
8471 */
8472 levelsup = rte->ctelevelsup;
8473 cteroot = root;
8474 while (levelsup-- > 0)
8475 {
8476 cteroot = cteroot->parent_root;
8477 if (!cteroot) /* shouldn't happen */
8478 elog(ERROR, "bad levelsup for CTE \"%s\"", rte->ctename);
8479 }
8480
8481 /*
8482 * Note: cte_plan_ids can be shorter than cteList, if we are still working
8483 * on planning the CTEs (ie, this is a side-reference from another CTE).
8484 * So we mustn't use forboth here.
8485 */
8486 ndx = 0;
8487 foreach(lc, cteroot->parse->cteList)
8488 {
8489 CommonTableExpr *cte = (CommonTableExpr *) lfirst(lc);
8490
8491 if (strcmp(cte->ctename, rte->ctename) == 0)
8492 break;
8493 ndx++;
8494 }
8495 if (lc == NULL) /* shouldn't happen */
8496 elog(ERROR, "could not find CTE \"%s\"", rte->ctename);
8497 if (ndx >= list_length(cteroot->cte_plan_ids))
8498 elog(ERROR, "could not find plan for CTE \"%s\"", rte->ctename);
8499 plan_id = list_nth_int(cteroot->cte_plan_ids, ndx);
8500 Assert(plan_id > 0);
8501=====================================================================
8502Found a 39 line (148 tokens) duplication in the following files:
8503Starting at line 2155 of /home/shackle/pggit/postgresql/src/backend/parser/parse_utilcmd.c
8504Starting at line 2278 of /home/shackle/pggit/postgresql/src/backend/parser/parse_utilcmd.c
8505
8506 RangeVar *inh = castNode(RangeVar, lfirst(inher));
8507 Relation rel;
8508 int count;
8509
8510 rel = heap_openrv(inh, AccessShareLock);
8511 /* check user requested inheritance from valid relkind */
8512 if (rel->rd_rel->relkind != RELKIND_RELATION &&
8513 rel->rd_rel->relkind != RELKIND_FOREIGN_TABLE &&
8514 rel->rd_rel->relkind != RELKIND_PARTITIONED_TABLE)
8515 ereport(ERROR,
8516 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
8517 errmsg("inherited relation \"%s\" is not a table or foreign table",
8518 inh->relname)));
8519 for (count = 0; count < rel->rd_att->natts; count++)
8520 {
8521 Form_pg_attribute inhattr = TupleDescAttr(rel->rd_att,
8522 count);
8523 char *inhname = NameStr(inhattr->attname);
8524
8525 if (inhattr->attisdropped)
8526 continue;
8527 if (strcmp(key, inhname) == 0)
8528 {
8529 found = true;
8530
8531 /*
8532 * We currently have no easy way to force an
8533 * inherited column to be NOT NULL at creation, if
8534 * its parent wasn't so already. We leave it to
8535 * DefineIndex to fix things up in this case.
8536 */
8537 break;
8538 }
8539 }
8540 heap_close(rel, NoLock);
8541 if (found)
8542 break;
8543 }
8544 }
8545=====================================================================
8546Found a 31 line (147 tokens) duplication in the following files:
8547Starting at line 1644 of /home/shackle/pggit/postgresql/src/backend/utils/adt/geo_ops.c
8548Starting at line 1699 of /home/shackle/pggit/postgresql/src/backend/utils/adt/geo_ops.c
8549
8550 PG_RETURN_BOOL(false);
8551
8552 /* pairwise check lseg intersections */
8553 for (i = 0; i < p1->npts; i++)
8554 {
8555 int iprev;
8556
8557 if (i > 0)
8558 iprev = i - 1;
8559 else
8560 {
8561 if (!p1->closed)
8562 continue;
8563 iprev = p1->npts - 1; /* include the closure segment */
8564 }
8565
8566 for (j = 0; j < p2->npts; j++)
8567 {
8568 int jprev;
8569
8570 if (j > 0)
8571 jprev = j - 1;
8572 else
8573 {
8574 if (!p2->closed)
8575 continue;
8576 jprev = p2->npts - 1; /* include the closure segment */
8577 }
8578
8579 statlseg_construct(&seg1, &p1->p[iprev], &p1->p[i]);
8580 statlseg_construct(&seg2, &p2->p[jprev], &p2->p[j]);
8581=====================================================================
8582Found a 31 line (146 tokens) duplication in the following files:
8583Starting at line 99 of /home/shackle/pggit/postgresql/src/tools/findoidjoins/findoidjoins.c
8584Starting at line 175 of /home/shackle/pggit/postgresql/src/tools/findoidjoins/findoidjoins.c
8585
8586 "ORDER BY nspname, c.relname, a.attnum"
8587 );
8588
8589 res = PQexec(conn, sql.data);
8590 if (!res || PQresultStatus(res) != PGRES_TUPLES_OK)
8591 {
8592 fprintf(stderr, "sql error: %s\n", PQerrorMessage(conn));
8593 exit(EXIT_FAILURE);
8594 }
8595 fkrel_res = res;
8596
8597 /*
8598 * For each column and each relation-having-OIDs, look to see if the
8599 * column contains any values matching entries in the relation.
8600 */
8601
8602 for (fk = 0; fk < PQntuples(fkrel_res); fk++)
8603 {
8604 fk_relname = PQgetvalue(fkrel_res, fk, 0);
8605 fk_nspname = PQgetvalue(fkrel_res, fk, 1);
8606 fk_attname = PQgetvalue(fkrel_res, fk, 2);
8607
8608 for (pk = 0; pk < PQntuples(pkrel_res); pk++)
8609 {
8610 pk_relname = PQgetvalue(pkrel_res, pk, 0);
8611 pk_nspname = PQgetvalue(pkrel_res, pk, 1);
8612
8613 printfPQExpBuffer(&sql,
8614 "SELECT 1 "
8615 "FROM \"%s\".\"%s\" t1, "
8616 "\"%s\".\"%s\" t2 "
8617=====================================================================
8618Found a 54 line (146 tokens) duplication in the following files:
8619Starting at line 729 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/numeric.c
8620Starting at line 857 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/numeric.c
8621
8622 if (var2->sign == NUMERIC_POS)
8623 {
8624 /*
8625 * Both are positive result = +(ABS(var1) + ABS(var2))
8626 */
8627 if (add_abs(var1, var2, result) != 0)
8628 return -1;
8629 result->sign = NUMERIC_POS;
8630 }
8631 else
8632 {
8633 /*
8634 * var1 is positive, var2 is negative Must compare absolute values
8635 */
8636 switch (cmp_abs(var1, var2))
8637 {
8638 case 0:
8639 /* ----------
8640 * ABS(var1) == ABS(var2)
8641 * result = ZERO
8642 * ----------
8643 */
8644 zero_var(result);
8645 result->rscale = Max(var1->rscale, var2->rscale);
8646 result->dscale = Max(var1->dscale, var2->dscale);
8647 break;
8648
8649 case 1:
8650 /* ----------
8651 * ABS(var1) > ABS(var2)
8652 * result = +(ABS(var1) - ABS(var2))
8653 * ----------
8654 */
8655 if (sub_abs(var1, var2, result) != 0)
8656 return -1;
8657 result->sign = NUMERIC_POS;
8658 break;
8659
8660 case -1:
8661 /* ----------
8662 * ABS(var1) < ABS(var2)
8663 * result = -(ABS(var2) - ABS(var1))
8664 * ----------
8665 */
8666 if (sub_abs(var2, var1, result) != 0)
8667 return -1;
8668 result->sign = NUMERIC_NEG;
8669 break;
8670 }
8671 }
8672 }
8673 else
8674 {
8675 if (var2->sign == NUMERIC_POS)
8676=====================================================================
8677Found a 35 line (146 tokens) duplication in the following files:
8678Starting at line 480 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/interval.c
8679Starting at line 3243 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
8680
8681 *fsec += rint((val + fval) * 1000);
8682 tmask = DTK_M(MILLISECOND);
8683 break;
8684
8685 case DTK_SECOND:
8686 tm->tm_sec += val;
8687 *fsec += rint(fval * 1000000);
8688
8689 /*
8690 * If any subseconds were specified, consider this
8691 * microsecond and millisecond input as well.
8692 */
8693 if (fval == 0)
8694 tmask = DTK_M(SECOND);
8695 else
8696 tmask = DTK_ALL_SECS_M;
8697 break;
8698
8699 case DTK_MINUTE:
8700 tm->tm_min += val;
8701 AdjustFractSeconds(fval, tm, fsec, SECS_PER_MINUTE);
8702 tmask = DTK_M(MINUTE);
8703 break;
8704
8705 case DTK_HOUR:
8706 tm->tm_hour += val;
8707 AdjustFractSeconds(fval, tm, fsec, SECS_PER_HOUR);
8708 tmask = DTK_M(HOUR);
8709 type = DTK_DAY;
8710 break;
8711
8712 case DTK_DAY:
8713 tm->tm_mday += val;
8714 AdjustFractSeconds(fval, tm, fsec, SECS_PER_DAY);
8715 tmask = (fmask & DTK_M(DAY)) ? 0 : DTK_M(DAY);
8716=====================================================================
8717Found a 18 line (146 tokens) duplication in the following files:
8718Starting at line 881 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/interval.c
8719Starting at line 4349 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
8720
8721 *cp = '\0';
8722 }
8723 break;
8724
8725 /* Compatible with postgresql < 8.4 when DateStyle = 'iso' */
8726 case INTSTYLE_POSTGRES:
8727 cp = AddPostgresIntPart(cp, year, "year", &is_zero, &is_before);
8728 cp = AddPostgresIntPart(cp, mon, "mon", &is_zero, &is_before);
8729 cp = AddPostgresIntPart(cp, mday, "day", &is_zero, &is_before);
8730 if (is_zero || hour != 0 || min != 0 || sec != 0 || fsec != 0)
8731 {
8732 bool minus = (hour < 0 || min < 0 || sec < 0 || fsec < 0);
8733
8734 sprintf(cp, "%s%s%02d:%02d:",
8735 is_zero ? "" : " ",
8736 (minus ? "-" : (is_before ? "+" : "")),
8737 abs(hour), abs(min));
8738 cp += strlen(cp);
8739=====================================================================
8740Found a 35 line (146 tokens) duplication in the following files:
8741Starting at line 1930 of /home/shackle/pggit/postgresql/src/backend/access/heap/tuptoaster.c
8742Starting at line 2155 of /home/shackle/pggit/postgresql/src/backend/access/heap/tuptoaster.c
8743
8744 &SnapshotToast, 1, &toastkey);
8745 while ((ttup = systable_getnext_ordered(toastscan, ForwardScanDirection)) != NULL)
8746 {
8747 /*
8748 * Have a chunk, extract the sequence number and the data
8749 */
8750 residx = DatumGetInt32(fastgetattr(ttup, 2, toasttupDesc, &isnull));
8751 Assert(!isnull);
8752 chunk = DatumGetPointer(fastgetattr(ttup, 3, toasttupDesc, &isnull));
8753 Assert(!isnull);
8754 if (!VARATT_IS_EXTENDED(chunk))
8755 {
8756 chunksize = VARSIZE(chunk) - VARHDRSZ;
8757 chunkdata = VARDATA(chunk);
8758 }
8759 else if (VARATT_IS_SHORT(chunk))
8760 {
8761 /* could happen due to heap_form_tuple doing its thing */
8762 chunksize = VARSIZE_SHORT(chunk) - VARHDRSZ_SHORT;
8763 chunkdata = VARDATA_SHORT(chunk);
8764 }
8765 else
8766 {
8767 /* should never happen */
8768 elog(ERROR, "found toasted toast chunk for toast value %u in %s",
8769 toast_pointer.va_valueid,
8770 RelationGetRelationName(toastrel));
8771 chunksize = 0; /* keep compiler quiet */
8772 chunkdata = NULL;
8773 }
8774
8775 /*
8776 * Some checks on the data we've found
8777 */
8778 if (residx != nextidx)
8779=====================================================================
8780Found a 26 line (145 tokens) duplication in the following files:
8781Starting at line 177 of /home/shackle/pggit/postgresql/src/port/qsort.c
8782Starting at line 177 of /home/shackle/pggit/postgresql/src/port/qsort_arg.c
8783
8784 while (pb <= pc && (r = cmp(pc, a)) >= 0)
8785 {
8786 if (r == 0)
8787 {
8788 swap(pc, pd);
8789 pd -= es;
8790 }
8791 pc -= es;
8792 }
8793 if (pb > pc)
8794 break;
8795 swap(pb, pc);
8796 pb += es;
8797 pc -= es;
8798 }
8799 pn = (char *) a + n * es;
8800 d1 = Min(pa - (char *) a, pb - pa);
8801 vecswap(a, pb - d1, d1);
8802 d1 = Min(pd - pc, pn - pd - es);
8803 vecswap(pb, pn - d1, d1);
8804 d1 = pb - pa;
8805 d2 = pd - pc;
8806 if (d1 <= d2)
8807 {
8808 /* Recurse on left partition, then iterate on right partition */
8809 if (d1 > es)
8810=====================================================================
8811Found a 10 line (145 tokens) duplication in the following files:
8812Starting at line 221 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-array.c
8813Starting at line 297 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-array.c
8814
8815 ECPGt_char,(text),(long)25,(long)1,(25)*sizeof(char),
8816 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
8817 ECPGt_timestamp,&(ts),(long)1,(long)10,sizeof(timestamp),
8818 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
8819 ECPGt_numeric,&(n),(long)1,(long)10,sizeof(numeric),
8820 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
8821 ECPGt_date,&(d),(long)1,(long)10,sizeof(date),
8822 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
8823 ECPGt_interval,&(in),(long)1,(long)10,sizeof(interval),
8824 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
8825=====================================================================
8826Found a 49 line (145 tokens) duplication in the following files:
8827Starting at line 1151 of /home/shackle/pggit/postgresql/src/backend/regex/regexec.c
8828Starting at line 1358 of /home/shackle/pggit/postgresql/src/backend/regex/regexec.c
8829
8830 limit = end;
8831 continue;
8832 }
8833
8834 /*
8835 * We've identified a way to divide the string into k sub-matches that
8836 * works so far as the child DFA can tell. If k is an allowed number
8837 * of matches, start the slow part: recurse to verify each sub-match.
8838 * We always have k <= max_matches, needn't check that.
8839 */
8840 if (k < min_matches)
8841 goto backtrack;
8842
8843 MDEBUG(("%d: verifying %d..%d\n", t->id, nverified + 1, k));
8844
8845 for (i = nverified + 1; i <= k; i++)
8846 {
8847 zaptreesubs(v, t->left);
8848 er = cdissect(v, t->left, endpts[i - 1], endpts[i]);
8849 if (er == REG_OKAY)
8850 {
8851 nverified = i;
8852 continue;
8853 }
8854 if (er == REG_NOMATCH)
8855 break;
8856 /* oops, something failed */
8857 FREE(endpts);
8858 return er;
8859 }
8860
8861 if (i > k)
8862 {
8863 /* satisfaction */
8864 MDEBUG(("%d successful\n", t->id));
8865 FREE(endpts);
8866 return REG_OKAY;
8867 }
8868
8869 /* match failed to verify, so backtrack */
8870
8871backtrack:
8872
8873 /*
8874 * Must consider shorter versions of the current sub-match. However,
8875 * we'll only ask for a zero-length match if necessary.
8876 */
8877 while (k > 0)
8878 {
8879=====================================================================
8880Found a 33 line (144 tokens) duplication in the following files:
8881Starting at line 904 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/ecpglib/execute.c
8882Starting at line 951 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/ecpglib/execute.c
8883Starting at line 998 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/ecpglib/execute.c
8884
8885 str = quote_postgres(PGTYPESinterval_to_asc(&(((interval *) (var->value))[element])), quote, lineno);
8886 if (!str)
8887 {
8888 ecpg_free(mallocedval);
8889 return false;
8890 }
8891
8892 slen = strlen(str);
8893
8894 if (!(newcopy = ecpg_realloc(mallocedval, strlen(mallocedval) + slen + 2, lineno)))
8895 {
8896 ecpg_free(mallocedval);
8897 ecpg_free(str);
8898 return false;
8899 }
8900 mallocedval = newcopy;
8901
8902 /* also copy trailing '\0' */
8903 memcpy(mallocedval + strlen(mallocedval), str, slen + 1);
8904 if (var->arrsize > 1)
8905 strcpy(mallocedval + strlen(mallocedval), ",");
8906
8907 ecpg_free(str);
8908 }
8909
8910 if (var->arrsize > 1)
8911 strcpy(mallocedval + strlen(mallocedval) - 1, "}");
8912
8913 *tobeinserted_p = mallocedval;
8914 }
8915 break;
8916
8917 case ECPGt_date:
8918=====================================================================
8919Found a 26 line (144 tokens) duplication in the following files:
8920Starting at line 1542 of /home/shackle/pggit/postgresql/src/backend/optimizer/plan/setrefs.c
8921Starting at line 2441 of /home/shackle/pggit/postgresql/src/backend/optimizer/plan/setrefs.c
8922
8923 return (Node *) var;
8924 }
8925 if (IsA(node, Param))
8926 return fix_param_node(context->root, (Param *) node);
8927 if (IsA(node, Aggref))
8928 {
8929 Aggref *aggref = (Aggref *) node;
8930
8931 /* See if the Aggref should be replaced by a Param */
8932 if (context->root->minmax_aggs != NIL &&
8933 list_length(aggref->args) == 1)
8934 {
8935 TargetEntry *curTarget = (TargetEntry *) linitial(aggref->args);
8936 ListCell *lc;
8937
8938 foreach(lc, context->root->minmax_aggs)
8939 {
8940 MinMaxAggInfo *mminfo = (MinMaxAggInfo *) lfirst(lc);
8941
8942 if (mminfo->aggfnoid == aggref->aggfnoid &&
8943 equal(mminfo->target, curTarget->expr))
8944 return (Node *) copyObject(mminfo->param);
8945 }
8946 }
8947 /* If no match, just fall through to process it normally */
8948 }
8949=====================================================================
8950Found a 27 line (143 tokens) duplication in the following files:
8951Starting at line 62 of /home/shackle/pggit/postgresql/src/test/isolation/isolation_main.c
8952Starting at line 50 of /home/shackle/pggit/postgresql/src/test/regress/pg_regress_main.c
8953
8954 snprintf(infile, sizeof(infile), "%s/specs/%s.spec",
8955 inputdir, testname);
8956
8957 snprintf(outfile, sizeof(outfile), "%s/results/%s.out",
8958 outputdir, testname);
8959
8960 snprintf(expectfile, sizeof(expectfile), "%s/expected/%s.out",
8961 outputdir, testname);
8962 if (!file_exists(expectfile))
8963 snprintf(expectfile, sizeof(expectfile), "%s/expected/%s.out",
8964 inputdir, testname);
8965
8966 add_stringlist_item(resultfiles, outfile);
8967 add_stringlist_item(expectfiles, expectfile);
8968
8969 if (launcher)
8970 {
8971 offset += snprintf(psql_cmd + offset, sizeof(psql_cmd) - offset,
8972 "%s ", launcher);
8973 if (offset >= sizeof(psql_cmd))
8974 {
8975 fprintf(stderr, _("command too long\n"));
8976 exit(2);
8977 }
8978 }
8979
8980 offset += snprintf(psql_cmd + offset, sizeof(psql_cmd) - offset,
8981=====================================================================
8982Found a 68 line (143 tokens) duplication in the following files:
8983Starting at line 782 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/numeric.c
8984Starting at line 914 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/numeric.c
8985
8986 if (var2->sign == NUMERIC_POS)
8987 {
8988 /* ----------
8989 * var1 is negative, var2 is positive
8990 * Must compare absolute values
8991 * ----------
8992 */
8993 switch (cmp_abs(var1, var2))
8994 {
8995 case 0:
8996 /* ----------
8997 * ABS(var1) == ABS(var2)
8998 * result = ZERO
8999 * ----------
9000 */
9001 zero_var(result);
9002 result->rscale = Max(var1->rscale, var2->rscale);
9003 result->dscale = Max(var1->dscale, var2->dscale);
9004 break;
9005
9006 case 1:
9007 /* ----------
9008 * ABS(var1) > ABS(var2)
9009 * result = -(ABS(var1) - ABS(var2))
9010 * ----------
9011 */
9012 if (sub_abs(var1, var2, result) != 0)
9013 return -1;
9014 result->sign = NUMERIC_NEG;
9015 break;
9016
9017 case -1:
9018 /* ----------
9019 * ABS(var1) < ABS(var2)
9020 * result = +(ABS(var2) - ABS(var1))
9021 * ----------
9022 */
9023 if (sub_abs(var2, var1, result) != 0)
9024 return -1;
9025 result->sign = NUMERIC_POS;
9026 break;
9027 }
9028 }
9029 else
9030 {
9031 /* ----------
9032 * Both are negative
9033 * result = -(ABS(var1) + ABS(var2))
9034 * ----------
9035 */
9036 if (add_abs(var1, var2, result) != 0)
9037 return -1;
9038 result->sign = NUMERIC_NEG;
9039 }
9040 }
9041
9042 return 0;
9043}
9044
9045
9046/* ----------
9047 * sub_var() -
9048 *
9049 * Full version of sub functionality on variable level (handling signs).
9050 * result might point to one of the operands too without danger.
9051 * ----------
9052 */
9053int
9054=====================================================================
9055Found a 12 line (143 tokens) duplication in the following files:
9056Starting at line 1737 of /home/shackle/pggit/postgresql/src/backend/utils/mb/wchar.c
9057Starting at line 1754 of /home/shackle/pggit/postgresql/src/backend/utils/mb/wchar.c
9058
9059 {pg_mule2wchar_with_len, pg_wchar2mule_with_len, pg_mule_mblen, pg_mule_dsplen, pg_mule_verifier, 4}, /* PG_MULE_INTERNAL */
9060 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN1 */
9061 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN2 */
9062 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN3 */
9063 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN4 */
9064 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN5 */
9065 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN6 */
9066 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN7 */
9067 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN8 */
9068 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN9 */
9069 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN10 */
9070 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_WIN1256 */
9071=====================================================================
9072Found a 30 line (143 tokens) duplication in the following files:
9073Starting at line 1584 of /home/shackle/pggit/postgresql/src/backend/utils/adt/formatting.c
9074Starting at line 1706 of /home/shackle/pggit/postgresql/src/backend/utils/adt/formatting.c
9075
9076 len_conv = icu_convert_case(u_strToLower, mylocale,
9077 &buff_conv, buff_uchar, len_uchar);
9078 icu_from_uchar(&result, buff_conv, len_conv);
9079 pfree(buff_uchar);
9080 }
9081 else
9082#endif
9083 {
9084 if (pg_database_encoding_max_length() > 1)
9085 {
9086 wchar_t *workspace;
9087 size_t curr_char;
9088 size_t result_size;
9089
9090 /* Overflow paranoia */
9091 if ((nbytes + 1) > (INT_MAX / sizeof(wchar_t)))
9092 ereport(ERROR,
9093 (errcode(ERRCODE_OUT_OF_MEMORY),
9094 errmsg("out of memory")));
9095
9096 /* Output workspace cannot have more codes than input bytes */
9097 workspace = (wchar_t *) palloc((nbytes + 1) * sizeof(wchar_t));
9098
9099 char2wchar(workspace, nbytes + 1, buff, nbytes, mylocale);
9100
9101 for (curr_char = 0; workspace[curr_char] != 0; curr_char++)
9102 {
9103#ifdef HAVE_LOCALE_T
9104 if (mylocale)
9105 workspace[curr_char] = towlower_l(workspace[curr_char], mylocale->info.lt);
9106=====================================================================
9107Found a 39 line (143 tokens) duplication in the following files:
9108Starting at line 5494 of /home/shackle/pggit/postgresql/src/backend/utils/adt/formatting.c
9109Starting at line 5802 of /home/shackle/pggit/postgresql/src/backend/utils/adt/formatting.c
9110
9111 NumericGetDatum(x)));
9112
9113 if (*orgnum == '-')
9114 {
9115 sign = '-';
9116 numstr = orgnum + 1;
9117 }
9118 else
9119 {
9120 sign = '+';
9121 numstr = orgnum;
9122 }
9123
9124 if ((p = strchr(numstr, '.')))
9125 numstr_pre_len = p - numstr;
9126 else
9127 numstr_pre_len = strlen(numstr);
9128
9129 /* needs padding? */
9130 if (numstr_pre_len < Num.pre)
9131 out_pre_spaces = Num.pre - numstr_pre_len;
9132 /* overflowed prefix digit format? */
9133 else if (numstr_pre_len > Num.pre)
9134 {
9135 numstr = (char *) palloc(Num.pre + Num.post + 2);
9136 fill_str(numstr, '#', Num.pre + Num.post + 1);
9137 *(numstr + Num.pre) = '.';
9138 }
9139 }
9140
9141 NUM_TOCHAR_finish;
9142 PG_RETURN_TEXT_P(result);
9143}
9144
9145/* ---------------
9146 * INT4 to_char()
9147 * ---------------
9148 */
9149Datum
9150=====================================================================
9151Found a 22 line (143 tokens) duplication in the following files:
9152Starting at line 481 of /home/shackle/pggit/postgresql/src/backend/utils/error/elog.c
9153Starting at line 1540 of /home/shackle/pggit/postgresql/src/backend/utils/error/elog.c
9154
9155 if (edata->message)
9156 pfree(edata->message);
9157 if (edata->detail)
9158 pfree(edata->detail);
9159 if (edata->detail_log)
9160 pfree(edata->detail_log);
9161 if (edata->hint)
9162 pfree(edata->hint);
9163 if (edata->context)
9164 pfree(edata->context);
9165 if (edata->schema_name)
9166 pfree(edata->schema_name);
9167 if (edata->table_name)
9168 pfree(edata->table_name);
9169 if (edata->column_name)
9170 pfree(edata->column_name);
9171 if (edata->datatype_name)
9172 pfree(edata->datatype_name);
9173 if (edata->constraint_name)
9174 pfree(edata->constraint_name);
9175 if (edata->internalquery)
9176 pfree(edata->internalquery);
9177=====================================================================
9178Found a 30 line (142 tokens) duplication in the following files:
9179Starting at line 186 of /home/shackle/pggit/postgresql/contrib/hstore/hstore_gist.c
9180Starting at line 105 of /home/shackle/pggit/postgresql/contrib/intarray/_intbig_gist.c
9181
9182ghstore_same(PG_FUNCTION_ARGS)
9183{
9184 GISTTYPE *a = (GISTTYPE *) PG_GETARG_POINTER(0);
9185 GISTTYPE *b = (GISTTYPE *) PG_GETARG_POINTER(1);
9186 bool *result = (bool *) PG_GETARG_POINTER(2);
9187
9188 if (ISALLTRUE(a) && ISALLTRUE(b))
9189 *result = true;
9190 else if (ISALLTRUE(a))
9191 *result = false;
9192 else if (ISALLTRUE(b))
9193 *result = false;
9194 else
9195 {
9196 int32 i;
9197 BITVECP sa = GETSIGN(a),
9198 sb = GETSIGN(b);
9199
9200 *result = true;
9201 LOOPBYTE
9202 {
9203 if (sa[i] != sb[i])
9204 {
9205 *result = false;
9206 break;
9207 }
9208 }
9209 }
9210 PG_RETURN_POINTER(result);
9211}
9212=====================================================================
9213Found a 30 line (142 tokens) duplication in the following files:
9214Starting at line 809 of /home/shackle/pggit/postgresql/contrib/hstore/hstore_io.c
9215Starting at line 110 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
9216Starting at line 483 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
9217
9218 tupdesc = lookup_rowtype_tupdesc_domain(tupType, tupTypmod, false);
9219 ncolumns = tupdesc->natts;
9220
9221 /*
9222 * We arrange to look up the needed I/O info just once per series of
9223 * calls, assuming the record type doesn't change underneath us.
9224 */
9225 my_extra = (RecordIOData *) fcinfo->flinfo->fn_extra;
9226 if (my_extra == NULL ||
9227 my_extra->ncolumns != ncolumns)
9228 {
9229 fcinfo->flinfo->fn_extra =
9230 MemoryContextAlloc(fcinfo->flinfo->fn_mcxt,
9231 offsetof(RecordIOData, columns) +
9232 ncolumns * sizeof(ColumnIOData));
9233 my_extra = (RecordIOData *) fcinfo->flinfo->fn_extra;
9234 my_extra->record_type = InvalidOid;
9235 my_extra->record_typmod = 0;
9236 }
9237
9238 if (my_extra->record_type != tupType ||
9239 my_extra->record_typmod != tupTypmod)
9240 {
9241 MemSet(my_extra, 0,
9242 offsetof(RecordIOData, columns) +
9243 ncolumns * sizeof(ColumnIOData));
9244 my_extra->record_type = tupType;
9245 my_extra->record_typmod = tupTypmod;
9246 my_extra->ncolumns = ncolumns;
9247 }
9248=====================================================================
9249Found a 77 line (142 tokens) duplication in the following files:
9250Starting at line 1315 of /home/shackle/pggit/postgresql/src/backend/utils/sort/tuplesort.c
9251Starting at line 578 of /home/shackle/pggit/postgresql/src/backend/utils/sort/tuplestore.c
9252
9253grow_memtuples(Tuplesortstate *state)
9254{
9255 int newmemtupsize;
9256 int memtupsize = state->memtupsize;
9257 int64 memNowUsed = state->allowedMem - state->availMem;
9258
9259 /* Forget it if we've already maxed out memtuples, per comment above */
9260 if (!state->growmemtuples)
9261 return false;
9262
9263 /* Select new value of memtupsize */
9264 if (memNowUsed <= state->availMem)
9265 {
9266 /*
9267 * We've used no more than half of allowedMem; double our usage,
9268 * clamping at INT_MAX tuples.
9269 */
9270 if (memtupsize < INT_MAX / 2)
9271 newmemtupsize = memtupsize * 2;
9272 else
9273 {
9274 newmemtupsize = INT_MAX;
9275 state->growmemtuples = false;
9276 }
9277 }
9278 else
9279 {
9280 /*
9281 * This will be the last increment of memtupsize. Abandon doubling
9282 * strategy and instead increase as much as we safely can.
9283 *
9284 * To stay within allowedMem, we can't increase memtupsize by more
9285 * than availMem / sizeof(SortTuple) elements. In practice, we want
9286 * to increase it by considerably less, because we need to leave some
9287 * space for the tuples to which the new array slots will refer. We
9288 * assume the new tuples will be about the same size as the tuples
9289 * we've already seen, and thus we can extrapolate from the space
9290 * consumption so far to estimate an appropriate new size for the
9291 * memtuples array. The optimal value might be higher or lower than
9292 * this estimate, but it's hard to know that in advance. We again
9293 * clamp at INT_MAX tuples.
9294 *
9295 * This calculation is safe against enlarging the array so much that
9296 * LACKMEM becomes true, because the memory currently used includes
9297 * the present array; thus, there would be enough allowedMem for the
9298 * new array elements even if no other memory were currently used.
9299 *
9300 * We do the arithmetic in float8, because otherwise the product of
9301 * memtupsize and allowedMem could overflow. Any inaccuracy in the
9302 * result should be insignificant; but even if we computed a
9303 * completely insane result, the checks below will prevent anything
9304 * really bad from happening.
9305 */
9306 double grow_ratio;
9307
9308 grow_ratio = (double) state->allowedMem / (double) memNowUsed;
9309 if (memtupsize * grow_ratio < INT_MAX)
9310 newmemtupsize = (int) (memtupsize * grow_ratio);
9311 else
9312 newmemtupsize = INT_MAX;
9313
9314 /* We won't make any further enlargement attempts */
9315 state->growmemtuples = false;
9316 }
9317
9318 /* Must enlarge array by at least one element, else report failure */
9319 if (newmemtupsize <= memtupsize)
9320 goto noalloc;
9321
9322 /*
9323 * On a 32-bit machine, allowedMem could exceed MaxAllocHugeSize. Clamp
9324 * to ensure our request won't be rejected. Note that we can easily
9325 * exhaust address space before facing this outcome. (This is presently
9326 * impossible due to guc.c's MAX_KILOBYTES limitation on work_mem, but
9327 * don't rely on that at this distance.)
9328 */
9329 if ((Size) newmemtupsize >= MaxAllocHugeSize / sizeof(SortTuple))
9330=====================================================================
9331Found a 33 line (142 tokens) duplication in the following files:
9332Starting at line 5494 of /home/shackle/pggit/postgresql/src/backend/utils/adt/formatting.c
9333Starting at line 5905 of /home/shackle/pggit/postgresql/src/backend/utils/adt/formatting.c
9334
9335 NumericGetDatum(x)));
9336
9337 if (*orgnum == '-')
9338 {
9339 sign = '-';
9340 numstr = orgnum + 1;
9341 }
9342 else
9343 {
9344 sign = '+';
9345 numstr = orgnum;
9346 }
9347
9348 if ((p = strchr(numstr, '.')))
9349 numstr_pre_len = p - numstr;
9350 else
9351 numstr_pre_len = strlen(numstr);
9352
9353 /* needs padding? */
9354 if (numstr_pre_len < Num.pre)
9355 out_pre_spaces = Num.pre - numstr_pre_len;
9356 /* overflowed prefix digit format? */
9357 else if (numstr_pre_len > Num.pre)
9358 {
9359 numstr = (char *) palloc(Num.pre + Num.post + 2);
9360 fill_str(numstr, '#', Num.pre + Num.post + 1);
9361 *(numstr + Num.pre) = '.';
9362 }
9363 }
9364
9365 NUM_TOCHAR_finish;
9366 PG_RETURN_TEXT_P(result);
9367}
9368=====================================================================
9369Found a 42 line (142 tokens) duplication in the following files:
9370Starting at line 3417 of /home/shackle/pggit/postgresql/src/backend/utils/adt/varlena.c
9371Starting at line 3538 of /home/shackle/pggit/postgresql/src/backend/utils/adt/varlena.c
9372
9373SplitDirectoriesString(char *rawstring, char separator,
9374 List **namelist)
9375{
9376 char *nextp = rawstring;
9377 bool done = false;
9378
9379 *namelist = NIL;
9380
9381 while (scanner_isspace(*nextp))
9382 nextp++; /* skip leading whitespace */
9383
9384 if (*nextp == '\0')
9385 return true; /* allow empty string */
9386
9387 /* At the top of the loop, we are at start of a new directory. */
9388 do
9389 {
9390 char *curname;
9391 char *endp;
9392
9393 if (*nextp == '"')
9394 {
9395 /* Quoted name --- collapse quote-quote pairs */
9396 curname = nextp + 1;
9397 for (;;)
9398 {
9399 endp = strchr(nextp + 1, '"');
9400 if (endp == NULL)
9401 return false; /* mismatched quotes */
9402 if (endp[1] != '"')
9403 break; /* found end of quoted name */
9404 /* Collapse adjacent quotes into one quote, and look again */
9405 memmove(endp, endp + 1, strlen(endp));
9406 nextp = endp;
9407 }
9408 /* endp now points at the terminating quote */
9409 nextp = endp + 1;
9410 }
9411 else
9412 {
9413 /* Unquoted name --- extends to separator or end of string */
9414 curname = endp = nextp;
9415=====================================================================
9416Found a 27 line (141 tokens) duplication in the following files:
9417Starting at line 308 of /home/shackle/pggit/postgresql/contrib/hstore/hstore_gist.c
9418Starting at line 301 of /home/shackle/pggit/postgresql/contrib/intarray/_intbig_gist.c
9419
9420ghstore_penalty(PG_FUNCTION_ARGS)
9421{
9422 GISTENTRY *origentry = (GISTENTRY *) PG_GETARG_POINTER(0); /* always ISSIGNKEY */
9423 GISTENTRY *newentry = (GISTENTRY *) PG_GETARG_POINTER(1);
9424 float *penalty = (float *) PG_GETARG_POINTER(2);
9425 GISTTYPE *origval = (GISTTYPE *) DatumGetPointer(origentry->key);
9426 GISTTYPE *newval = (GISTTYPE *) DatumGetPointer(newentry->key);
9427
9428 *penalty = hemdist(origval, newval);
9429 PG_RETURN_POINTER(penalty);
9430}
9431
9432
9433typedef struct
9434{
9435 OffsetNumber pos;
9436 int32 cost;
9437} SPLITCOST;
9438
9439static int
9440comparecost(const void *a, const void *b)
9441{
9442 return ((const SPLITCOST *) a)->cost - ((const SPLITCOST *) b)->cost;
9443}
9444
9445
9446Datum
9447=====================================================================
9448Found a 3 line (141 tokens) duplication in the following files:
9449Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
9450Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
9451Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
9452
9453 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
9454 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
9455 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
9456=====================================================================
9457Found a 3 line (141 tokens) duplication in the following files:
9458Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
9459Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
9460Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
9461
9462 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
9463 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
9464 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
9465=====================================================================
9466Found a 22 line (141 tokens) duplication in the following files:
9467Starting at line 261 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/compat_informix-describe.c
9468Starting at line 388 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-describe.c
9469
9470 for (i = 1; i <= count1; i++)
9471 {
9472 { ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
9473 ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
9474
9475#line 115 "describe.pgc"
9476
9477if (sqlca.sqlcode < 0) exit (1);}
9478#line 115 "describe.pgc"
9479
9480 { ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
9481 ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
9482
9483#line 116 "describe.pgc"
9484
9485if (sqlca.sqlcode < 0) exit (1);}
9486#line 116 "describe.pgc"
9487
9488 printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
9489 "sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n",
9490 i, field_name1, field_name2,
9491 sqlda1->sqlvar[i-1].sqlname,
9492=====================================================================
9493Found a 22 line (141 tokens) duplication in the following files:
9494Starting at line 390 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/compat_informix-describe.c
9495Starting at line 259 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-describe.c
9496
9497 for (i = 1; i <= count1; i++)
9498 {
9499 { ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
9500 ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
9501
9502#line 168 "describe.pgc"
9503
9504if (sqlca.sqlcode < 0) exit (1);}
9505#line 168 "describe.pgc"
9506
9507 { ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
9508 ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
9509
9510#line 169 "describe.pgc"
9511
9512if (sqlca.sqlcode < 0) exit (1);}
9513#line 169 "describe.pgc"
9514
9515 printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
9516 "sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n",
9517 i, field_name1, field_name2,
9518 sqlda1->sqlvar[i-1].sqlname,
9519=====================================================================
9520Found a 23 line (141 tokens) duplication in the following files:
9521Starting at line 49 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-show.c
9522Starting at line 71 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-show.c
9523
9524 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
9525#line 18 "show.pgc"
9526
9527if (sqlca.sqlwarn[0] == 'W') sqlprint();
9528#line 18 "show.pgc"
9529
9530if (sqlca.sqlcode < 0) sqlprint();}
9531#line 18 "show.pgc"
9532
9533 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "show search_path", ECPGt_EOIT,
9534 ECPGt_char,(var),(long)25,(long)1,(25)*sizeof(char),
9535 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
9536#line 19 "show.pgc"
9537
9538if (sqlca.sqlwarn[0] == 'W') sqlprint();
9539#line 19 "show.pgc"
9540
9541if (sqlca.sqlcode < 0) sqlprint();}
9542#line 19 "show.pgc"
9543
9544 printf("Var: Search path: %s\n", var);
9545
9546 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set search_path to 'public'", ECPGt_EOIT, ECPGt_EORT);
9547=====================================================================
9548Found a 25 line (141 tokens) duplication in the following files:
9549Starting at line 64 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-quote.c
9550Starting at line 108 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-quote.c
9551
9552 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set standard_conforming_strings to off", ECPGt_EOIT, ECPGt_EORT);
9553#line 22 "quote.pgc"
9554
9555if (sqlca.sqlwarn[0] == 'W') sqlprint();
9556#line 22 "quote.pgc"
9557
9558if (sqlca.sqlcode < 0) sqlprint();}
9559#line 22 "quote.pgc"
9560
9561
9562 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "show standard_conforming_strings", ECPGt_EOIT,
9563 ECPGt_char,(var),(long)25,(long)1,(25)*sizeof(char),
9564 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
9565#line 24 "quote.pgc"
9566
9567if (sqlca.sqlwarn[0] == 'W') sqlprint();
9568#line 24 "quote.pgc"
9569
9570if (sqlca.sqlcode < 0) sqlprint();}
9571#line 24 "quote.pgc"
9572
9573 printf("Standard conforming strings: %s\n", var);
9574
9575 /* this is a\\b actually */
9576 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into \"My_Table\" values ( 1 , 'a\\\\\\\\b' )", ECPGt_EOIT, ECPGt_EORT);
9577=====================================================================
9578Found a 39 line (141 tokens) duplication in the following files:
9579Starting at line 363 of /home/shackle/pggit/postgresql/src/backend/executor/nodeWindowAgg.c
9580Starting at line 529 of /home/shackle/pggit/postgresql/src/backend/executor/nodeWindowAgg.c
9581
9582 peraggstate->transValueCount++;
9583
9584 /*
9585 * If pass-by-ref datatype, must copy the new value into aggcontext and
9586 * free the prior transValue. But if transfn returned a pointer to its
9587 * first input, we don't need to do anything. Also, if transfn returned a
9588 * pointer to a R/W expanded object that is already a child of the
9589 * aggcontext, assume we can adopt that value without copying it.
9590 */
9591 if (!peraggstate->transtypeByVal &&
9592 DatumGetPointer(newVal) != DatumGetPointer(peraggstate->transValue))
9593 {
9594 if (!fcinfo->isnull)
9595 {
9596 MemoryContextSwitchTo(peraggstate->aggcontext);
9597 if (DatumIsReadWriteExpandedObject(newVal,
9598 false,
9599 peraggstate->transtypeLen) &&
9600 MemoryContextGetParent(DatumGetEOHP(newVal)->eoh_context) == CurrentMemoryContext)
9601 /* do nothing */ ;
9602 else
9603 newVal = datumCopy(newVal,
9604 peraggstate->transtypeByVal,
9605 peraggstate->transtypeLen);
9606 }
9607 if (!peraggstate->transValueIsNull)
9608 {
9609 if (DatumIsReadWriteExpandedObject(peraggstate->transValue,
9610 false,
9611 peraggstate->transtypeLen))
9612 DeleteExpandedObject(peraggstate->transValue);
9613 else
9614 pfree(DatumGetPointer(peraggstate->transValue));
9615 }
9616 }
9617
9618 MemoryContextSwitchTo(oldContext);
9619 peraggstate->transValue = newVal;
9620 peraggstate->transValueIsNull = fcinfo->isnull;
9621=====================================================================
9622Found a 33 line (141 tokens) duplication in the following files:
9623Starting at line 1279 of /home/shackle/pggit/postgresql/src/backend/executor/nodeIndexscan.c
9624Starting at line 1409 of /home/shackle/pggit/postgresql/src/backend/executor/nodeIndexscan.c
9625
9626 rightop = (Expr *) get_rightop(clause);
9627
9628 if (rightop && IsA(rightop, RelabelType))
9629 rightop = ((RelabelType *) rightop)->arg;
9630
9631 Assert(rightop != NULL);
9632
9633 if (IsA(rightop, Const))
9634 {
9635 /* OK, simple constant comparison value */
9636 scanvalue = ((Const *) rightop)->constvalue;
9637 if (((Const *) rightop)->constisnull)
9638 flags |= SK_ISNULL;
9639 }
9640 else
9641 {
9642 /* Need to treat this one as a runtime key */
9643 if (n_runtime_keys >= max_runtime_keys)
9644 {
9645 if (max_runtime_keys == 0)
9646 {
9647 max_runtime_keys = 8;
9648 runtime_keys = (IndexRuntimeKeyInfo *)
9649 palloc(max_runtime_keys * sizeof(IndexRuntimeKeyInfo));
9650 }
9651 else
9652 {
9653 max_runtime_keys *= 2;
9654 runtime_keys = (IndexRuntimeKeyInfo *)
9655 repalloc(runtime_keys, max_runtime_keys * sizeof(IndexRuntimeKeyInfo));
9656 }
9657 }
9658 runtime_keys[n_runtime_keys].scan_key = this_scan_key;
9659=====================================================================
9660Found a 46 line (141 tokens) duplication in the following files:
9661Starting at line 1321 of /home/shackle/pggit/postgresql/src/backend/utils/adt/int8.c
9662Starting at line 1375 of /home/shackle/pggit/postgresql/src/backend/utils/adt/int.c
9663
9664 step = PG_GETARG_INT64(2);
9665 if (step == 0)
9666 ereport(ERROR,
9667 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
9668 errmsg("step size cannot equal zero")));
9669
9670 /* create a function context for cross-call persistence */
9671 funcctx = SRF_FIRSTCALL_INIT();
9672
9673 /*
9674 * switch to memory context appropriate for multiple function calls
9675 */
9676 oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
9677
9678 /* allocate memory for user context */
9679 fctx = (generate_series_fctx *) palloc(sizeof(generate_series_fctx));
9680
9681 /*
9682 * Use fctx to keep state from call to call. Seed current with the
9683 * original start value
9684 */
9685 fctx->current = start;
9686 fctx->finish = finish;
9687 fctx->step = step;
9688
9689 funcctx->user_fctx = fctx;
9690 MemoryContextSwitchTo(oldcontext);
9691 }
9692
9693 /* stuff done on every call of the function */
9694 funcctx = SRF_PERCALL_SETUP();
9695
9696 /*
9697 * get the saved state and use current as the result for this iteration
9698 */
9699 fctx = funcctx->user_fctx;
9700 result = fctx->current;
9701
9702 if ((fctx->step > 0 && fctx->current <= fctx->finish) ||
9703 (fctx->step < 0 && fctx->current >= fctx->finish))
9704 {
9705 /*
9706 * Increment current in preparation for next iteration. If next-value
9707 * computation overflows, this is the final result.
9708 */
9709 if (pg_add_s64_overflow(fctx->current, fctx->step, &fctx->current))
9710=====================================================================
9711Found a 26 line (141 tokens) duplication in the following files:
9712Starting at line 47 of /home/shackle/pggit/postgresql/src/backend/utils/adt/jsonb_op.c
9713Starting at line 80 of /home/shackle/pggit/postgresql/src/backend/utils/adt/jsonb_op.c
9714
9715jsonb_exists_any(PG_FUNCTION_ARGS)
9716{
9717 Jsonb *jb = PG_GETARG_JSONB_P(0);
9718 ArrayType *keys = PG_GETARG_ARRAYTYPE_P(1);
9719 int i;
9720 Datum *key_datums;
9721 bool *key_nulls;
9722 int elem_count;
9723
9724 deconstruct_array(keys, TEXTOID, -1, false, 'i', &key_datums, &key_nulls,
9725 &elem_count);
9726
9727 for (i = 0; i < elem_count; i++)
9728 {
9729 JsonbValue strVal;
9730
9731 if (key_nulls[i])
9732 continue;
9733
9734 strVal.type = jbvString;
9735 strVal.val.string.val = VARDATA(key_datums[i]);
9736 strVal.val.string.len = VARSIZE(key_datums[i]) - VARHDRSZ;
9737
9738 if (findJsonbValueFromContainer(&jb->root,
9739 JB_FOBJECT | JB_FARRAY,
9740 &strVal) != NULL)
9741=====================================================================
9742Found a 19 line (141 tokens) duplication in the following files:
9743Starting at line 177 of /home/shackle/pggit/postgresql/src/backend/access/common/tupconvert.c
9744Starting at line 219 of /home/shackle/pggit/postgresql/src/backend/access/common/tupconvert.c
9745
9746 return NULL;
9747 }
9748
9749 /* Prepare the map structure */
9750 map = (TupleConversionMap *) palloc(sizeof(TupleConversionMap));
9751 map->indesc = indesc;
9752 map->outdesc = outdesc;
9753 map->attrMap = attrMap;
9754 /* preallocate workspace for Datum arrays */
9755 map->outvalues = (Datum *) palloc(n * sizeof(Datum));
9756 map->outisnull = (bool *) palloc(n * sizeof(bool));
9757 n = indesc->natts + 1; /* +1 for NULL */
9758 map->invalues = (Datum *) palloc(n * sizeof(Datum));
9759 map->inisnull = (bool *) palloc(n * sizeof(bool));
9760 map->invalues[0] = (Datum) 0; /* set up the NULL entry */
9761 map->inisnull[0] = true;
9762
9763 return map;
9764}
9765=====================================================================
9766Found a 18 line (140 tokens) duplication in the following files:
9767Starting at line 246 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/thread-prep.c
9768Starting at line 205 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/thread-alloc.c
9769
9770 for (i = 0; i < THREADS; ++i)
9771 {
9772 unsigned id;
9773 threads[i] = (HANDLE)_beginthreadex(NULL, 0, fn, (void*)i, 0, &id);
9774 }
9775
9776 WaitForMultipleObjects(THREADS, threads, TRUE, INFINITE);
9777 for (i = 0; i < THREADS; ++i)
9778 CloseHandle(threads[i]);
9779#else
9780 for (i = 0; i < THREADS; ++i)
9781 pthread_create(&threads[i], NULL, fn, (void *) (long) i);
9782 for (i = 0; i < THREADS; ++i)
9783 pthread_join(threads[i], NULL);
9784#endif
9785
9786 return 0;
9787}
9788=====================================================================
9789Found a 20 line (140 tokens) duplication in the following files:
9790Starting at line 2046 of /home/shackle/pggit/postgresql/src/backend/tsearch/wparser_def.c
9791Starting at line 2417 of /home/shackle/pggit/postgresql/src/backend/tsearch/wparser_def.c
9792
9793 for (i = startpos; i <= endpos; i++)
9794 {
9795 if (prs->words[i].item)
9796 prs->words[i].selected = 1;
9797 if (highlight == 0)
9798 {
9799 if (HLIDREPLACE(prs->words[i].type))
9800 prs->words[i].replace = 1;
9801 else if (HLIDSKIP(prs->words[i].type))
9802 prs->words[i].skip = 1;
9803 }
9804 else
9805 {
9806 if (XMLHLIDSKIP(prs->words[i].type))
9807 prs->words[i].skip = 1;
9808 }
9809
9810 prs->words[i].in = (prs->words[i].repeated) ? 0 : 1;
9811 }
9812}
9813=====================================================================
9814Found a 38 line (140 tokens) duplication in the following files:
9815Starting at line 5399 of /home/shackle/pggit/postgresql/src/backend/utils/adt/timestamp.c
9816Starting at line 5480 of /home/shackle/pggit/postgresql/src/backend/utils/adt/timestamp.c
9817
9818 palloc(sizeof(generate_series_timestamp_fctx));
9819
9820 /*
9821 * Use fctx to keep state from call to call. Seed current with the
9822 * original start value
9823 */
9824 fctx->current = start;
9825 fctx->finish = finish;
9826 fctx->step = *step;
9827
9828 /* Determine sign of the interval */
9829 MemSet(&interval_zero, 0, sizeof(Interval));
9830 fctx->step_sign = interval_cmp_internal(&fctx->step, &interval_zero);
9831
9832 if (fctx->step_sign == 0)
9833 ereport(ERROR,
9834 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
9835 errmsg("step size cannot equal zero")));
9836
9837 funcctx->user_fctx = fctx;
9838 MemoryContextSwitchTo(oldcontext);
9839 }
9840
9841 /* stuff done on every call of the function */
9842 funcctx = SRF_PERCALL_SETUP();
9843
9844 /*
9845 * get the saved state and use current as the result for this iteration
9846 */
9847 fctx = funcctx->user_fctx;
9848 result = fctx->current;
9849
9850 if (fctx->step_sign > 0 ?
9851 timestamp_cmp_internal(result, fctx->finish) <= 0 :
9852 timestamp_cmp_internal(result, fctx->finish) >= 0)
9853 {
9854 /* increment current in preparation for next iteration */
9855 fctx->current = DatumGetTimestamp(
9856=====================================================================
9857Found a 40 line (140 tokens) duplication in the following files:
9858Starting at line 3290 of /home/shackle/pggit/postgresql/src/backend/utils/adt/varlena.c
9859Starting at line 3417 of /home/shackle/pggit/postgresql/src/backend/utils/adt/varlena.c
9860Starting at line 3538 of /home/shackle/pggit/postgresql/src/backend/utils/adt/varlena.c
9861
9862SplitIdentifierString(char *rawstring, char separator,
9863 List **namelist)
9864{
9865 char *nextp = rawstring;
9866 bool done = false;
9867
9868 *namelist = NIL;
9869
9870 while (scanner_isspace(*nextp))
9871 nextp++; /* skip leading whitespace */
9872
9873 if (*nextp == '\0')
9874 return true; /* allow empty string */
9875
9876 /* At the top of the loop, we are at start of a new identifier. */
9877 do
9878 {
9879 char *curname;
9880 char *endp;
9881
9882 if (*nextp == '"')
9883 {
9884 /* Quoted name --- collapse quote-quote pairs, no downcasing */
9885 curname = nextp + 1;
9886 for (;;)
9887 {
9888 endp = strchr(nextp + 1, '"');
9889 if (endp == NULL)
9890 return false; /* mismatched quotes */
9891 if (endp[1] != '"')
9892 break; /* found end of quoted name */
9893 /* Collapse adjacent quotes into one quote, and look again */
9894 memmove(endp, endp + 1, strlen(endp));
9895 nextp = endp;
9896 }
9897 /* endp now points at the terminating quote */
9898 nextp = endp + 1;
9899 }
9900 else
9901 {
9902=====================================================================
9903Found a 43 line (140 tokens) duplication in the following files:
9904Starting at line 988 of /home/shackle/pggit/postgresql/src/backend/commands/typecmds.c
9905Starting at line 2569 of /home/shackle/pggit/postgresql/src/backend/commands/typecmds.c
9906
9907 break;
9908
9909 /*
9910 * All else are error cases
9911 */
9912 case CONSTR_UNIQUE:
9913 ereport(ERROR,
9914 (errcode(ERRCODE_SYNTAX_ERROR),
9915 errmsg("unique constraints not possible for domains")));
9916 break;
9917
9918 case CONSTR_PRIMARY:
9919 ereport(ERROR,
9920 (errcode(ERRCODE_SYNTAX_ERROR),
9921 errmsg("primary key constraints not possible for domains")));
9922 break;
9923
9924 case CONSTR_EXCLUSION:
9925 ereport(ERROR,
9926 (errcode(ERRCODE_SYNTAX_ERROR),
9927 errmsg("exclusion constraints not possible for domains")));
9928 break;
9929
9930 case CONSTR_FOREIGN:
9931 ereport(ERROR,
9932 (errcode(ERRCODE_SYNTAX_ERROR),
9933 errmsg("foreign key constraints not possible for domains")));
9934 break;
9935
9936 case CONSTR_ATTR_DEFERRABLE:
9937 case CONSTR_ATTR_NOT_DEFERRABLE:
9938 case CONSTR_ATTR_DEFERRED:
9939 case CONSTR_ATTR_IMMEDIATE:
9940 ereport(ERROR,
9941 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
9942 errmsg("specifying constraint deferrability not supported for domains")));
9943 break;
9944
9945 default:
9946 elog(ERROR, "unrecognized constraint subtype: %d",
9947 (int) constr->contype);
9948 break;
9949 }
9950=====================================================================
9951Found a 41 line (140 tokens) duplication in the following files:
9952Starting at line 4124 of /home/shackle/pggit/postgresql/src/backend/commands/copy.c
9953Starting at line 4354 of /home/shackle/pggit/postgresql/src/backend/commands/copy.c
9954
9955 char delimc = cstate->delim[0];
9956 int fieldno;
9957 char *output_ptr;
9958 char *cur_ptr;
9959 char *line_end_ptr;
9960
9961 /*
9962 * We need a special case for zero-column tables: check that the input
9963 * line is empty, and return.
9964 */
9965 if (cstate->max_fields <= 0)
9966 {
9967 if (cstate->line_buf.len != 0)
9968 ereport(ERROR,
9969 (errcode(ERRCODE_BAD_COPY_FILE_FORMAT),
9970 errmsg("extra data after last expected column")));
9971 return 0;
9972 }
9973
9974 resetStringInfo(&cstate->attribute_buf);
9975
9976 /*
9977 * The de-escaped attributes will certainly not be longer than the input
9978 * data line, so we can just force attribute_buf to be large enough and
9979 * then transfer data without any checks for enough space. We need to do
9980 * it this way because enlarging attribute_buf mid-stream would invalidate
9981 * pointers already stored into cstate->raw_fields[].
9982 */
9983 if (cstate->attribute_buf.maxlen <= cstate->line_buf.len)
9984 enlargeStringInfo(&cstate->attribute_buf, cstate->line_buf.len);
9985 output_ptr = cstate->attribute_buf.data;
9986
9987 /* set pointer variables for loop */
9988 cur_ptr = cstate->line_buf.data;
9989 line_end_ptr = cstate->line_buf.data + cstate->line_buf.len;
9990
9991 /* Outer loop iterates over fields */
9992 fieldno = 0;
9993 for (;;)
9994 {
9995 bool found_delim = false;
9996=====================================================================
9997Found a 14 line (139 tokens) duplication in the following files:
9998Starting at line 119 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-binary.c
9999Starting at line 150 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-binary.c
10000
10001 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch C", ECPGt_EOIT,
10002 ECPGt_char,(empl.name),(long)21,(long)1,(21)*sizeof(char),
10003 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
10004 ECPGt_short,&(empl.accs),(long)1,(long)1,sizeof(short),
10005 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
10006 ECPGt_char,(empl.byte),(long)20,(long)1,(20)*sizeof(char),
10007 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
10008#line 60 "binary.pgc"
10009
10010 if (sqlca.sqlcode)
10011 {
10012 printf ("fetch error = %ld\n", sqlca.sqlcode);
10013 exit (sqlca.sqlcode);
10014 }
10015=====================================================================
10016Found a 20 line (139 tokens) duplication in the following files:
10017Starting at line 1243 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
10018Starting at line 1553 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
10019
10020 InitFunctionCallInfoData(fcinfo, flinfo, 6, collation, NULL, NULL);
10021
10022 fcinfo.arg[0] = arg1;
10023 fcinfo.arg[1] = arg2;
10024 fcinfo.arg[2] = arg3;
10025 fcinfo.arg[3] = arg4;
10026 fcinfo.arg[4] = arg5;
10027 fcinfo.arg[5] = arg6;
10028 fcinfo.argnull[0] = false;
10029 fcinfo.argnull[1] = false;
10030 fcinfo.argnull[2] = false;
10031 fcinfo.argnull[3] = false;
10032 fcinfo.argnull[4] = false;
10033 fcinfo.argnull[5] = false;
10034
10035 result = FunctionCallInvoke(&fcinfo);
10036
10037 /* Check for null result, since caller is clearly not expecting one */
10038 if (fcinfo.isnull)
10039 elog(ERROR, "function %u returned NULL", fcinfo.flinfo->fn_oid);
10040=====================================================================
10041Found a 24 line (139 tokens) duplication in the following files:
10042Starting at line 8626 of /home/shackle/pggit/postgresql/src/backend/utils/adt/numeric.c
10043Starting at line 8711 of /home/shackle/pggit/postgresql/src/backend/utils/adt/numeric.c
10044
10045 res_weight = Max(var1->weight, var2->weight) + 1;
10046
10047 res_dscale = Max(var1->dscale, var2->dscale);
10048
10049 /* Note: here we are figuring rscale in base-NBASE digits */
10050 rscale1 = var1->ndigits - var1->weight - 1;
10051 rscale2 = var2->ndigits - var2->weight - 1;
10052 res_rscale = Max(rscale1, rscale2);
10053
10054 res_ndigits = res_rscale + res_weight + 1;
10055 if (res_ndigits <= 0)
10056 res_ndigits = 1;
10057
10058 res_buf = digitbuf_alloc(res_ndigits + 1);
10059 res_buf[0] = 0; /* spare digit for later rounding */
10060 res_digits = res_buf + 1;
10061
10062 i1 = res_rscale + var1->weight + 1;
10063 i2 = res_rscale + var2->weight + 1;
10064 for (i = res_ndigits - 1; i >= 0; i--)
10065 {
10066 i1--;
10067 i2--;
10068 if (i1 >= 0 && i1 < var1ndigits)
10069=====================================================================
10070Found a 38 line (139 tokens) duplication in the following files:
10071Starting at line 109 of /home/shackle/pggit/postgresql/src/backend/utils/adt/expandedrecord.c
10072Starting at line 242 of /home/shackle/pggit/postgresql/src/backend/utils/adt/expandedrecord.c
10073
10074 tupdesc_id = assign_record_type_identifier(type_id, typmod);
10075 }
10076
10077 /*
10078 * Allocate private context for expanded object. We use a regular-size
10079 * context, not a small one, to improve the odds that we can fit a tupdesc
10080 * into it without needing an extra malloc block. (This code path doesn't
10081 * ever need to copy a tupdesc into the expanded record, but let's be
10082 * consistent with the other ways of making an expanded record.)
10083 */
10084 objcxt = AllocSetContextCreate(parentcontext,
10085 "expanded record",
10086 ALLOCSET_DEFAULT_SIZES);
10087
10088 /*
10089 * Since we already know the number of fields in the tupdesc, we can
10090 * allocate the dvalues/dnulls arrays along with the record header. This
10091 * is useless if we never need those arrays, but it costs almost nothing,
10092 * and it will save a palloc cycle if we do need them.
10093 */
10094 erh = (ExpandedRecordHeader *)
10095 MemoryContextAlloc(objcxt, MAXALIGN(sizeof(ExpandedRecordHeader))
10096 + tupdesc->natts * (sizeof(Datum) + sizeof(bool)));
10097
10098 /* Ensure all header fields are initialized to 0/null */
10099 memset(erh, 0, sizeof(ExpandedRecordHeader));
10100
10101 EOH_init_header(&erh->hdr, &ER_methods, objcxt);
10102 erh->er_magic = ER_MAGIC;
10103
10104 /* Set up dvalues/dnulls, with no valid contents as yet */
10105 chunk = (char *) erh + MAXALIGN(sizeof(ExpandedRecordHeader));
10106 erh->dvalues = (Datum *) chunk;
10107 erh->dnulls = (bool *) (chunk + tupdesc->natts * sizeof(Datum));
10108 erh->nfields = tupdesc->natts;
10109
10110 /* Fill in composite-type identification info */
10111 erh->er_decltypeid = type_id;
10112=====================================================================
10113Found a 31 line (138 tokens) duplication in the following files:
10114Starting at line 110 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_backup_custom.c
10115Starting at line 111 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_backup_directory.c
10116
10117InitArchiveFmt_Custom(ArchiveHandle *AH)
10118{
10119 lclContext *ctx;
10120
10121 /* Assuming static functions, this can be copied for each format. */
10122 AH->ArchiveEntryPtr = _ArchiveEntry;
10123 AH->StartDataPtr = _StartData;
10124 AH->WriteDataPtr = _WriteData;
10125 AH->EndDataPtr = _EndData;
10126 AH->WriteBytePtr = _WriteByte;
10127 AH->ReadBytePtr = _ReadByte;
10128 AH->WriteBufPtr = _WriteBuf;
10129 AH->ReadBufPtr = _ReadBuf;
10130 AH->ClosePtr = _CloseArchive;
10131 AH->ReopenPtr = _ReopenArchive;
10132 AH->PrintTocDataPtr = _PrintTocData;
10133 AH->ReadExtraTocPtr = _ReadExtraToc;
10134 AH->WriteExtraTocPtr = _WriteExtraToc;
10135 AH->PrintExtraTocPtr = _PrintExtraToc;
10136
10137 AH->StartBlobsPtr = _StartBlobs;
10138 AH->StartBlobPtr = _StartBlob;
10139 AH->EndBlobPtr = _EndBlob;
10140 AH->EndBlobsPtr = _EndBlobs;
10141
10142 AH->PrepParallelRestorePtr = _PrepParallelRestore;
10143 AH->ClonePtr = _Clone;
10144 AH->DeClonePtr = _DeClone;
10145
10146 /* no parallel dump in the custom archive, only parallel restore */
10147 AH->WorkerJobDumpPtr = NULL;
10148=====================================================================
10149Found a 3 line (138 tokens) duplication in the following files:
10150Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
10151Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
10152Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
10153
10154 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
10155 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
10156 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
10157=====================================================================
10158Found a 3 line (138 tokens) duplication in the following files:
10159Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
10160Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
10161Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
10162
10163 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
10164 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
10165 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
10166=====================================================================
10167Found a 18 line (138 tokens) duplication in the following files:
10168Starting at line 955 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
10169Starting at line 1275 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
10170Starting at line 1588 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
10171
10172 InitFunctionCallInfoData(fcinfo, NULL, 7, collation, NULL, NULL);
10173
10174 fcinfo.arg[0] = arg1;
10175 fcinfo.arg[1] = arg2;
10176 fcinfo.arg[2] = arg3;
10177 fcinfo.arg[3] = arg4;
10178 fcinfo.arg[4] = arg5;
10179 fcinfo.arg[5] = arg6;
10180 fcinfo.arg[6] = arg7;
10181 fcinfo.argnull[0] = false;
10182 fcinfo.argnull[1] = false;
10183 fcinfo.argnull[2] = false;
10184 fcinfo.argnull[3] = false;
10185 fcinfo.argnull[4] = false;
10186 fcinfo.argnull[5] = false;
10187 fcinfo.argnull[6] = false;
10188
10189 result = (*func) (&fcinfo);
10190=====================================================================
10191Found a 29 line (138 tokens) duplication in the following files:
10192Starting at line 1584 of /home/shackle/pggit/postgresql/src/backend/utils/adt/formatting.c
10193Starting at line 1706 of /home/shackle/pggit/postgresql/src/backend/utils/adt/formatting.c
10194Starting at line 1829 of /home/shackle/pggit/postgresql/src/backend/utils/adt/formatting.c
10195
10196 len_conv = icu_convert_case(u_strToLower, mylocale,
10197 &buff_conv, buff_uchar, len_uchar);
10198 icu_from_uchar(&result, buff_conv, len_conv);
10199 pfree(buff_uchar);
10200 }
10201 else
10202#endif
10203 {
10204 if (pg_database_encoding_max_length() > 1)
10205 {
10206 wchar_t *workspace;
10207 size_t curr_char;
10208 size_t result_size;
10209
10210 /* Overflow paranoia */
10211 if ((nbytes + 1) > (INT_MAX / sizeof(wchar_t)))
10212 ereport(ERROR,
10213 (errcode(ERRCODE_OUT_OF_MEMORY),
10214 errmsg("out of memory")));
10215
10216 /* Output workspace cannot have more codes than input bytes */
10217 workspace = (wchar_t *) palloc((nbytes + 1) * sizeof(wchar_t));
10218
10219 char2wchar(workspace, nbytes + 1, buff, nbytes, mylocale);
10220
10221 for (curr_char = 0; workspace[curr_char] != 0; curr_char++)
10222 {
10223#ifdef HAVE_LOCALE_T
10224 if (mylocale)
10225=====================================================================
10226Found a 38 line (138 tokens) duplication in the following files:
10227Starting at line 770 of /home/shackle/pggit/postgresql/src/backend/utils/adt/orderedsetaggs.c
10228Starting at line 894 of /home/shackle/pggit/postgresql/src/backend/utils/adt/orderedsetaggs.c
10229
10230 false);
10231
10232 result_datum = (Datum *) palloc(num_percentiles * sizeof(Datum));
10233 result_isnull = (bool *) palloc(num_percentiles * sizeof(bool));
10234
10235 /*
10236 * Start by dealing with any nulls in the param array - those are sorted
10237 * to the front on row=0, so set the corresponding result indexes to null
10238 */
10239 for (i = 0; i < num_percentiles; i++)
10240 {
10241 int idx = pct_info[i].idx;
10242
10243 if (pct_info[i].first_row > 0)
10244 break;
10245
10246 result_datum[idx] = (Datum) 0;
10247 result_isnull[idx] = true;
10248 }
10249
10250 /*
10251 * If there's anything left after doing the nulls, then grind the input
10252 * and extract the needed values
10253 */
10254 if (i < num_percentiles)
10255 {
10256 /* Finish the sort, or rescan if we already did */
10257 if (!osastate->sort_done)
10258 {
10259 tuplesort_performsort(osastate->sortstate);
10260 osastate->sort_done = true;
10261 }
10262 else
10263 tuplesort_rescan(osastate->sortstate);
10264
10265 for (; i < num_percentiles; i++)
10266 {
10267 int64 target_row = pct_info[i].first_row;
10268=====================================================================
10269Found a 31 line (137 tokens) duplication in the following files:
10270Starting at line 261 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/ecpglib/data.c
10271Starting at line 535 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/ecpglib/data.c
10272
10273 if (varcharsize * offset < size)
10274 {
10275 /* truncation */
10276 switch (ind_type)
10277 {
10278 case ECPGt_short:
10279 case ECPGt_unsigned_short:
10280 *((short *) (ind + ind_offset * act_tuple)) = size;
10281 break;
10282 case ECPGt_int:
10283 case ECPGt_unsigned_int:
10284 *((int *) (ind + ind_offset * act_tuple)) = size;
10285 break;
10286 case ECPGt_long:
10287 case ECPGt_unsigned_long:
10288 *((long *) (ind + ind_offset * act_tuple)) = size;
10289 break;
10290#ifdef HAVE_LONG_LONG_INT
10291 case ECPGt_long_long:
10292 case ECPGt_unsigned_long_long:
10293 *((long long int *) (ind + ind_offset * act_tuple)) = size;
10294 break;
10295#endif /* HAVE_LONG_LONG_INT */
10296 default:
10297 break;
10298 }
10299 sqlca->sqlwarn[0] = sqlca->sqlwarn[1] = 'W';
10300 }
10301 }
10302 pval += size;
10303 }
10304=====================================================================
10305Found a 21 line (137 tokens) duplication in the following files:
10306Starting at line 93 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-show.c
10307Starting at line 64 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-quote.c
10308
10309 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set standard_conforming_strings to off", ECPGt_EOIT, ECPGt_EORT);
10310#line 26 "show.pgc"
10311
10312if (sqlca.sqlwarn[0] == 'W') sqlprint();
10313#line 26 "show.pgc"
10314
10315if (sqlca.sqlcode < 0) sqlprint();}
10316#line 26 "show.pgc"
10317
10318 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "show standard_conforming_strings", ECPGt_EOIT,
10319 ECPGt_char,(var),(long)25,(long)1,(25)*sizeof(char),
10320 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
10321#line 27 "show.pgc"
10322
10323if (sqlca.sqlwarn[0] == 'W') sqlprint();
10324#line 27 "show.pgc"
10325
10326if (sqlca.sqlcode < 0) sqlprint();}
10327#line 27 "show.pgc"
10328
10329 printf("Var: Standard conforming strings: %s\n", var);
10330=====================================================================
10331Found a 25 line (136 tokens) duplication in the following files:
10332Starting at line 38 of /home/shackle/pggit/postgresql/src/port/pgstrcasecmp.c
10333Starting at line 71 of /home/shackle/pggit/postgresql/src/port/pgstrcasecmp.c
10334
10335 for (;;)
10336 {
10337 unsigned char ch1 = (unsigned char) *s1++;
10338 unsigned char ch2 = (unsigned char) *s2++;
10339
10340 if (ch1 != ch2)
10341 {
10342 if (ch1 >= 'A' && ch1 <= 'Z')
10343 ch1 += 'a' - 'A';
10344 else if (IS_HIGHBIT_SET(ch1) && isupper(ch1))
10345 ch1 = tolower(ch1);
10346
10347 if (ch2 >= 'A' && ch2 <= 'Z')
10348 ch2 += 'a' - 'A';
10349 else if (IS_HIGHBIT_SET(ch2) && isupper(ch2))
10350 ch2 = tolower(ch2);
10351
10352 if (ch1 != ch2)
10353 return (int) ch1 - (int) ch2;
10354 }
10355 if (ch1 == 0)
10356 break;
10357 }
10358 return 0;
10359}
10360=====================================================================
10361Found a 26 line (136 tokens) duplication in the following files:
10362Starting at line 56 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/interval.c
10363Starting at line 3452 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
10364
10365ParseISO8601Number(const char *str, char **endptr, int *ipart, double *fpart)
10366{
10367 double val;
10368
10369 if (!(isdigit((unsigned char) *str) || *str == '-' || *str == '.'))
10370 return DTERR_BAD_FORMAT;
10371 errno = 0;
10372 val = strtod(str, endptr);
10373 /* did we not see anything that looks like a double? */
10374 if (*endptr == str || errno != 0)
10375 return DTERR_BAD_FORMAT;
10376 /* watch out for overflow */
10377 if (val < INT_MIN || val > INT_MAX)
10378 return DTERR_FIELD_OVERFLOW;
10379 /* be very sure we truncate towards zero (cf dtrunc()) */
10380 if (val >= 0)
10381 *ipart = (int) floor(val);
10382 else
10383 *ipart = (int) -floor(-val);
10384 *fpart = val - *ipart;
10385 return 0;
10386}
10387
10388/* copy&pasted from .../src/backend/utils/adt/datetime.c */
10389static int
10390ISO8601IntegerWidth(const char *fieldstart)
10391=====================================================================
10392Found a 23 line (136 tokens) duplication in the following files:
10393Starting at line 116 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-fetch.c
10394Starting at line 195 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-fetch.c
10395
10396 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 in C", ECPGt_EOIT,
10397 ECPGt_int,&(i),(long)1,(long)1,sizeof(int),
10398 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
10399 ECPGt_char,(str),(long)25,(long)1,(25)*sizeof(char),
10400 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
10401#line 32 "fetch.pgc"
10402
10403if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
10404#line 32 "fetch.pgc"
10405
10406if (sqlca.sqlwarn[0] == 'W') sqlprint();
10407#line 32 "fetch.pgc"
10408
10409if (sqlca.sqlcode < 0) sqlprint();}
10410#line 32 "fetch.pgc"
10411
10412 printf("%d: %s\n", i, str);
10413 }
10414
10415 /* exec sql whenever not found continue ; */
10416#line 36 "fetch.pgc"
10417
10418 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "move backward 2 in C", ECPGt_EOIT, ECPGt_EORT);
10419=====================================================================
10420Found a 15 line (136 tokens) duplication in the following files:
10421Starting at line 200 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
10422Starting at line 215 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
10423Starting at line 230 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
10424Starting at line 248 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
10425Starting at line 273 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
10426Starting at line 291 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
10427
10428 { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch forward from $0",
10429 ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
10430 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
10431 ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
10432 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
10433 ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
10434 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
10435#line 70 "cursor.pgc"
10436
10437if (sqlca.sqlcode < 0) exit (1);}
10438#line 70 "cursor.pgc"
10439
10440 printf("%d %s\n", id, t);
10441
10442 strcpy(msg, "fetch");
10443=====================================================================
10444Found a 15 line (136 tokens) duplication in the following files:
10445Starting at line 340 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
10446Starting at line 355 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
10447Starting at line 370 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
10448Starting at line 388 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
10449Starting at line 417 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
10450Starting at line 435 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
10451
10452 { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch from $0",
10453 ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
10454 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
10455 ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
10456 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
10457 ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
10458 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
10459#line 111 "cursor.pgc"
10460
10461if (sqlca.sqlcode < 0) exit (1);}
10462#line 111 "cursor.pgc"
10463
10464 printf("%d %s\n", id, t);
10465
10466 strcpy(msg, "fetch");
10467=====================================================================
10468Found a 15 line (136 tokens) duplication in the following files:
10469Starting at line 523 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
10470Starting at line 538 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
10471Starting at line 556 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
10472Starting at line 581 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
10473Starting at line 599 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
10474
10475 { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch from $0",
10476 ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char),
10477 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
10478 ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
10479 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
10480 ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
10481 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
10482#line 161 "cursor.pgc"
10483
10484if (sqlca.sqlcode < 0) exit (1);}
10485#line 161 "cursor.pgc"
10486
10487 printf("%d %s\n", id, t);
10488
10489 strcpy(msg, "fetch 1 from");
10490=====================================================================
10491Found a 28 line (136 tokens) duplication in the following files:
10492Starting at line 119 of /home/shackle/pggit/postgresql/src/backend/utils/adt/expandedrecord.c
10493Starting at line 250 of /home/shackle/pggit/postgresql/src/backend/utils/adt/expandedrecord.c
10494Starting at line 342 of /home/shackle/pggit/postgresql/src/backend/utils/adt/expandedrecord.c
10495
10496 objcxt = AllocSetContextCreate(parentcontext,
10497 "expanded record",
10498 ALLOCSET_DEFAULT_SIZES);
10499
10500 /*
10501 * Since we already know the number of fields in the tupdesc, we can
10502 * allocate the dvalues/dnulls arrays along with the record header. This
10503 * is useless if we never need those arrays, but it costs almost nothing,
10504 * and it will save a palloc cycle if we do need them.
10505 */
10506 erh = (ExpandedRecordHeader *)
10507 MemoryContextAlloc(objcxt, MAXALIGN(sizeof(ExpandedRecordHeader))
10508 + tupdesc->natts * (sizeof(Datum) + sizeof(bool)));
10509
10510 /* Ensure all header fields are initialized to 0/null */
10511 memset(erh, 0, sizeof(ExpandedRecordHeader));
10512
10513 EOH_init_header(&erh->hdr, &ER_methods, objcxt);
10514 erh->er_magic = ER_MAGIC;
10515
10516 /* Set up dvalues/dnulls, with no valid contents as yet */
10517 chunk = (char *) erh + MAXALIGN(sizeof(ExpandedRecordHeader));
10518 erh->dvalues = (Datum *) chunk;
10519 erh->dnulls = (bool *) (chunk + tupdesc->natts * sizeof(Datum));
10520 erh->nfields = tupdesc->natts;
10521
10522 /* Fill in composite-type identification info */
10523 erh->er_decltypeid = type_id;
10524=====================================================================
10525Found a 33 line (136 tokens) duplication in the following files:
10526Starting at line 1263 of /home/shackle/pggit/postgresql/src/backend/utils/adt/ri_triggers.c
10527Starting at line 1450 of /home/shackle/pggit/postgresql/src/backend/utils/adt/ri_triggers.c
10528
10529 "%s %s = NULL",
10530 querysep, attname);
10531 sprintf(paramname, "$%d", i + 1);
10532 ri_GenerateQual(&qualbuf, qualsep,
10533 paramname, pk_type,
10534 riinfo->pf_eq_oprs[i],
10535 attname, fk_type);
10536 querysep = ",";
10537 qualsep = "AND";
10538 queryoids[i] = pk_type;
10539 }
10540 appendStringInfoString(&querybuf, qualbuf.data);
10541
10542 /* Prepare and save the plan */
10543 qplan = ri_PlanCheck(querybuf.data, riinfo->nkeys, queryoids,
10544 &qkey, fk_rel, pk_rel, true);
10545 }
10546
10547 /*
10548 * We have a plan now. Run it to update the existing references.
10549 */
10550 ri_PerformCheck(riinfo, &qkey, qplan,
10551 fk_rel, pk_rel,
10552 old_row, NULL,
10553 true, /* must detect new rows */
10554 SPI_OK_UPDATE);
10555
10556 if (SPI_finish() != SPI_OK_FINISH)
10557 elog(ERROR, "SPI_finish failed");
10558
10559 heap_close(fk_rel, RowExclusiveLock);
10560
10561 return PointerGetDatum(NULL);
10562=====================================================================
10563Found a 15 line (136 tokens) duplication in the following files:
10564Starting at line 605 of /home/shackle/pggit/postgresql/src/backend/bootstrap/bootstrap.c
10565Starting at line 931 of /home/shackle/pggit/postgresql/src/backend/bootstrap/bootstrap.c
10566
10567 rel = heap_open(TypeRelationId, NoLock);
10568 scan = heap_beginscan_catalog(rel, 0, NULL);
10569 i = 0;
10570 while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL)
10571 ++i;
10572 heap_endscan(scan);
10573 app = Typ = ALLOC(struct typmap *, i + 1);
10574 while (i-- > 0)
10575 *app++ = ALLOC(struct typmap, 1);
10576 *app = NULL;
10577 scan = heap_beginscan_catalog(rel, 0, NULL);
10578 app = Typ;
10579 while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL)
10580 {
10581 (*app)->am_oid = ((Form_pg_type) GETSTRUCT(tup))->oid;
10582=====================================================================
10583Found a 29 line (135 tokens) duplication in the following files:
10584Starting at line 810 of /home/shackle/pggit/postgresql/contrib/hstore/hstore_io.c
10585Starting at line 328 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
10586Starting at line 675 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
10587
10588 ncolumns = tupdesc->natts;
10589
10590 /*
10591 * We arrange to look up the needed I/O info just once per series of
10592 * calls, assuming the record type doesn't change underneath us.
10593 */
10594 my_extra = (RecordIOData *) fcinfo->flinfo->fn_extra;
10595 if (my_extra == NULL ||
10596 my_extra->ncolumns != ncolumns)
10597 {
10598 fcinfo->flinfo->fn_extra =
10599 MemoryContextAlloc(fcinfo->flinfo->fn_mcxt,
10600 offsetof(RecordIOData, columns) +
10601 ncolumns * sizeof(ColumnIOData));
10602 my_extra = (RecordIOData *) fcinfo->flinfo->fn_extra;
10603 my_extra->record_type = InvalidOid;
10604 my_extra->record_typmod = 0;
10605 }
10606
10607 if (my_extra->record_type != tupType ||
10608 my_extra->record_typmod != tupTypmod)
10609 {
10610 MemSet(my_extra, 0,
10611 offsetof(RecordIOData, columns) +
10612 ncolumns * sizeof(ColumnIOData));
10613 my_extra->record_type = tupType;
10614 my_extra->record_typmod = tupTypmod;
10615 my_extra->ncolumns = ncolumns;
10616 }
10617=====================================================================
10618Found a 3 line (135 tokens) duplication in the following files:
10619Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
10620Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
10621Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
10622
10623 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
10624 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
10625 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
10626=====================================================================
10627Found a 3 line (135 tokens) duplication in the following files:
10628Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
10629Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
10630Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
10631
10632 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
10633 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
10634 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
10635=====================================================================
10636Found a 30 line (135 tokens) duplication in the following files:
10637Starting at line 785 of /home/shackle/pggit/postgresql/src/backend/regex/regexec.c
10638Starting at line 863 of /home/shackle/pggit/postgresql/src/backend/regex/regexec.c
10639
10640 mid = longest(v, d, begin, end, (int *) NULL);
10641 NOERR();
10642 if (mid == NULL)
10643 return REG_NOMATCH;
10644 MDEBUG(("tentative midpoint %ld\n", LOFF(mid)));
10645
10646 /* iterate until satisfaction or failure */
10647 for (;;)
10648 {
10649 /* try this midpoint on for size */
10650 if (longest(v, d2, mid, end, (int *) NULL) == end)
10651 {
10652 er = cdissect(v, t->left, begin, mid);
10653 if (er == REG_OKAY)
10654 {
10655 er = cdissect(v, t->right, mid, end);
10656 if (er == REG_OKAY)
10657 {
10658 /* satisfaction */
10659 MDEBUG(("successful\n"));
10660 return REG_OKAY;
10661 }
10662 }
10663 if (er != REG_NOMATCH)
10664 return er;
10665 }
10666 NOERR();
10667
10668 /* that midpoint didn't work, find a new one */
10669 if (mid == begin)
10670=====================================================================
10671Found a 38 line (135 tokens) duplication in the following files:
10672Starting at line 4745 of /home/shackle/pggit/postgresql/src/backend/postmaster/pgstat.c
10673Starting at line 4880 of /home/shackle/pggit/postgresql/src/backend/postmaster/pgstat.c
10674
10675 rc = fwrite(dbentry, offsetof(PgStat_StatDBEntry, tables), 1, fpout);
10676 (void) rc; /* we'll check for error with ferror */
10677 }
10678
10679 /*
10680 * No more output to be done. Close the temp file and replace the old
10681 * pgstat.stat with it. The ferror() check replaces testing for error
10682 * after each individual fputc or fwrite above.
10683 */
10684 fputc('E', fpout);
10685
10686 if (ferror(fpout))
10687 {
10688 ereport(LOG,
10689 (errcode_for_file_access(),
10690 errmsg("could not write temporary statistics file \"%s\": %m",
10691 tmpfile)));
10692 FreeFile(fpout);
10693 unlink(tmpfile);
10694 }
10695 else if (FreeFile(fpout) < 0)
10696 {
10697 ereport(LOG,
10698 (errcode_for_file_access(),
10699 errmsg("could not close temporary statistics file \"%s\": %m",
10700 tmpfile)));
10701 unlink(tmpfile);
10702 }
10703 else if (rename(tmpfile, statfile) < 0)
10704 {
10705 ereport(LOG,
10706 (errcode_for_file_access(),
10707 errmsg("could not rename temporary statistics file \"%s\" to \"%s\": %m",
10708 tmpfile, statfile)));
10709 unlink(tmpfile);
10710 }
10711
10712 if (permanent)
10713=====================================================================
10714Found a 39 line (135 tokens) duplication in the following files:
10715Starting at line 263 of /home/shackle/pggit/postgresql/src/backend/utils/time/tqual.c
10716Starting at line 848 of /home/shackle/pggit/postgresql/src/backend/utils/time/tqual.c
10717
10718 else if (TransactionIdDidCommit(HeapTupleHeaderGetRawXmin(tuple)))
10719 SetHintBits(tuple, buffer, HEAP_XMIN_COMMITTED,
10720 HeapTupleHeaderGetRawXmin(tuple));
10721 else
10722 {
10723 /* it must have aborted or crashed */
10724 SetHintBits(tuple, buffer, HEAP_XMIN_INVALID,
10725 InvalidTransactionId);
10726 return false;
10727 }
10728 }
10729
10730 /* by here, the inserting transaction has committed */
10731
10732 if (tuple->t_infomask & HEAP_XMAX_INVALID) /* xid invalid or aborted */
10733 return true;
10734
10735 if (tuple->t_infomask & HEAP_XMAX_COMMITTED)
10736 {
10737 if (HEAP_XMAX_IS_LOCKED_ONLY(tuple->t_infomask))
10738 return true;
10739 return false; /* updated by other */
10740 }
10741
10742 if (tuple->t_infomask & HEAP_XMAX_IS_MULTI)
10743 {
10744 TransactionId xmax;
10745
10746 if (HEAP_XMAX_IS_LOCKED_ONLY(tuple->t_infomask))
10747 return true;
10748
10749 xmax = HeapTupleGetUpdateXid(tuple);
10750
10751 /* not LOCKED_ONLY, so it has to have an xmax */
10752 Assert(TransactionIdIsValid(xmax));
10753
10754 if (TransactionIdIsCurrentTransactionId(xmax))
10755 return false;
10756 if (TransactionIdIsInProgress(xmax))
10757=====================================================================
10758Found a 26 line (134 tokens) duplication in the following files:
10759Starting at line 78 of /home/shackle/pggit/postgresql/src/test/modules/test_rls_hooks/test_rls_hooks.c
10760Starting at line 143 of /home/shackle/pggit/postgresql/src/test/modules/test_rls_hooks/test_rls_hooks.c
10761
10762 if (strcmp(RelationGetRelationName(relation), "rls_test_permissive")
10763 && strcmp(RelationGetRelationName(relation), "rls_test_both"))
10764 return NIL;
10765
10766 qual_pstate = make_parsestate(NULL);
10767
10768 rte = addRangeTableEntryForRelation(qual_pstate, relation, AccessShareLock,
10769 NULL, false, false);
10770 addRTEtoQuery(qual_pstate, rte, false, true, true);
10771
10772 role = ObjectIdGetDatum(ACL_ID_PUBLIC);
10773
10774 policy->policy_name = pstrdup("extension policy");
10775 policy->polcmd = '*';
10776 policy->roles = construct_array(&role, 1, OIDOID, sizeof(Oid), true, 'i');
10777
10778 /*
10779 * policy->qual = (Expr *) makeConst(BOOLOID, -1, InvalidOid,
10780 * sizeof(bool), BoolGetDatum(true), false, true);
10781 */
10782
10783 n = makeFuncCall(list_make2(makeString("pg_catalog"),
10784 makeString("current_user")), NIL, 0);
10785
10786 c = makeNode(ColumnRef);
10787 c->fields = list_make1(makeString("username"));
10788=====================================================================
10789Found a 4 line (134 tokens) duplication in the following files:
10790Starting at line 30 of /home/shackle/pggit/postgresql/src/common/base64.c
10791Starting at line 3562 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
10792Starting at line 114 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
10793Starting at line 206 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
10794Starting at line 40 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
10795
10796static const int8 b64lookup[128] = {
10797 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
10798 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
10799 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
10800=====================================================================
10801Found a 16 line (134 tokens) duplication in the following files:
10802Starting at line 2020 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
10803Starting at line 2085 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
10804
10805 return InvalidOid;
10806
10807 if (IsA(expr, FuncExpr))
10808 args = ((FuncExpr *) expr)->args;
10809 else if (IsA(expr, OpExpr))
10810 args = ((OpExpr *) expr)->args;
10811 else if (IsA(expr, DistinctExpr))
10812 args = ((DistinctExpr *) expr)->args;
10813 else if (IsA(expr, ScalarArrayOpExpr))
10814 args = ((ScalarArrayOpExpr *) expr)->args;
10815 else if (IsA(expr, NullIfExpr))
10816 args = ((NullIfExpr *) expr)->args;
10817 else if (IsA(expr, WindowFunc))
10818 args = ((WindowFunc *) expr)->args;
10819 else
10820 return InvalidOid;
10821=====================================================================
10822Found a 28 line (134 tokens) duplication in the following files:
10823Starting at line 518 of /home/shackle/pggit/postgresql/src/backend/access/nbtree/nbtpage.c
10824Starting at line 606 of /home/shackle/pggit/postgresql/src/backend/access/nbtree/nbtpage.c
10825
10826 rel->rd_amcache = NULL;
10827
10828 metabuf = _bt_getbuf(rel, BTREE_METAPAGE, BT_READ);
10829 metapg = BufferGetPage(metabuf);
10830 metaopaque = (BTPageOpaque) PageGetSpecialPointer(metapg);
10831 metad = BTPageGetMeta(metapg);
10832
10833 if (!P_ISMETA(metaopaque) ||
10834 metad->btm_magic != BTREE_MAGIC)
10835 ereport(ERROR,
10836 (errcode(ERRCODE_INDEX_CORRUPTED),
10837 errmsg("index \"%s\" is not a btree",
10838 RelationGetRelationName(rel))));
10839
10840 if (metad->btm_version < BTREE_MIN_VERSION ||
10841 metad->btm_version > BTREE_VERSION)
10842 ereport(ERROR,
10843 (errcode(ERRCODE_INDEX_CORRUPTED),
10844 errmsg("version mismatch in index \"%s\": file version %d, "
10845 "current version %d, minimal supported version %d",
10846 RelationGetRelationName(rel),
10847 metad->btm_version, BTREE_VERSION, BTREE_MIN_VERSION)));
10848
10849 /* if no root page initialized yet, fail */
10850 if (metad->btm_root == P_NONE)
10851 {
10852 _bt_relbuf(rel, metabuf);
10853 return InvalidBuffer;
10854=====================================================================
10855Found a 15 line (133 tokens) duplication in the following files:
10856Starting at line 678 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
10857Starting at line 693 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
10858Starting at line 708 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
10859Starting at line 726 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
10860Starting at line 751 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
10861Starting at line 769 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
10862
10863 { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch from $0",
10864 ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1),
10865 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
10866 ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
10867 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
10868 ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
10869 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
10870#line 209 "cursor.pgc"
10871
10872if (sqlca.sqlcode < 0) exit (1);}
10873#line 209 "cursor.pgc"
10874
10875 printf("%d %s\n", id, t);
10876
10877 strcpy(msg, "fetch");
10878=====================================================================
10879Found a 31 line (133 tokens) duplication in the following files:
10880Starting at line 1284 of /home/shackle/pggit/postgresql/src/backend/executor/nodeIndexscan.c
10881Starting at line 1533 of /home/shackle/pggit/postgresql/src/backend/executor/nodeIndexscan.c
10882
10883 Assert(rightop != NULL);
10884
10885 if (IsA(rightop, Const))
10886 {
10887 /* OK, simple constant comparison value */
10888 scanvalue = ((Const *) rightop)->constvalue;
10889 if (((Const *) rightop)->constisnull)
10890 flags |= SK_ISNULL;
10891 }
10892 else
10893 {
10894 /* Need to treat this one as a runtime key */
10895 if (n_runtime_keys >= max_runtime_keys)
10896 {
10897 if (max_runtime_keys == 0)
10898 {
10899 max_runtime_keys = 8;
10900 runtime_keys = (IndexRuntimeKeyInfo *)
10901 palloc(max_runtime_keys * sizeof(IndexRuntimeKeyInfo));
10902 }
10903 else
10904 {
10905 max_runtime_keys *= 2;
10906 runtime_keys = (IndexRuntimeKeyInfo *)
10907 repalloc(runtime_keys, max_runtime_keys * sizeof(IndexRuntimeKeyInfo));
10908 }
10909 }
10910 runtime_keys[n_runtime_keys].scan_key = this_scan_key;
10911 runtime_keys[n_runtime_keys].key_expr =
10912 ExecInitExpr(rightop, planstate);
10913 runtime_keys[n_runtime_keys].key_toastable =
10914=====================================================================
10915Found a 40 line (133 tokens) duplication in the following files:
10916Starting at line 6344 of /home/shackle/pggit/postgresql/src/backend/utils/adt/numeric.c
10917Starting at line 6463 of /home/shackle/pggit/postgresql/src/backend/utils/adt/numeric.c
10918
10919 alloc_var(var, 20 / DEC_DIGITS);
10920 if (val < 0)
10921 {
10922 var->sign = NUMERIC_NEG;
10923 uval = -val;
10924 }
10925 else
10926 {
10927 var->sign = NUMERIC_POS;
10928 uval = val;
10929 }
10930 var->dscale = 0;
10931 if (val == 0)
10932 {
10933 var->ndigits = 0;
10934 var->weight = 0;
10935 return;
10936 }
10937 ptr = var->digits + var->ndigits;
10938 ndigits = 0;
10939 do
10940 {
10941 ptr--;
10942 ndigits++;
10943 newuval = uval / NBASE;
10944 *ptr = uval - newuval * NBASE;
10945 uval = newuval;
10946 } while (uval);
10947 var->digits = ptr;
10948 var->ndigits = ndigits;
10949 var->weight = ndigits - 1;
10950}
10951
10952#ifdef HAVE_INT128
10953/*
10954 * Convert numeric to int128, rounding if needed.
10955 *
10956 * If overflow, return false (no error is raised). Return true if okay.
10957 */
10958static bool
10959=====================================================================
10960Found a 26 line (133 tokens) duplication in the following files:
10961Starting at line 1467 of /home/shackle/pggit/postgresql/src/backend/commands/event_trigger.c
10962Starting at line 2019 of /home/shackle/pggit/postgresql/src/backend/commands/event_trigger.c
10963
10964 "pg_event_trigger_dropped_objects()")));
10965
10966 /* check to see if caller supports us returning a tuplestore */
10967 if (rsinfo == NULL || !IsA(rsinfo, ReturnSetInfo))
10968 ereport(ERROR,
10969 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
10970 errmsg("set-valued function called in context that cannot accept a set")));
10971 if (!(rsinfo->allowedModes & SFRM_Materialize))
10972 ereport(ERROR,
10973 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
10974 errmsg("materialize mode required, but it is not allowed in this context")));
10975
10976 /* Build a tuple descriptor for our result type */
10977 if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
10978 elog(ERROR, "return type must be a row type");
10979
10980 /* Build tuplestore to hold the result rows */
10981 per_query_ctx = rsinfo->econtext->ecxt_per_query_memory;
10982 oldcontext = MemoryContextSwitchTo(per_query_ctx);
10983
10984 tupstore = tuplestore_begin_heap(true, false, work_mem);
10985 rsinfo->returnMode = SFRM_Materialize;
10986 rsinfo->setResult = tupstore;
10987 rsinfo->setDesc = tupdesc;
10988
10989 MemoryContextSwitchTo(oldcontext);
10990=====================================================================
10991Found a 23 line (133 tokens) duplication in the following files:
10992Starting at line 56 of /home/shackle/pggit/postgresql/src/backend/access/brin/brin_validate.c
10993Starting at line 56 of /home/shackle/pggit/postgresql/src/backend/access/nbtree/nbtvalidate.c
10994Starting at line 59 of /home/shackle/pggit/postgresql/src/backend/access/spgist/spgvalidate.c
10995Starting at line 61 of /home/shackle/pggit/postgresql/src/backend/access/hash/hashvalidate.c
10996
10997 ListCell *lc;
10998
10999 /* Fetch opclass information */
11000 classtup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclassoid));
11001 if (!HeapTupleIsValid(classtup))
11002 elog(ERROR, "cache lookup failed for operator class %u", opclassoid);
11003 classform = (Form_pg_opclass) GETSTRUCT(classtup);
11004
11005 opfamilyoid = classform->opcfamily;
11006 opcintype = classform->opcintype;
11007 opclassname = NameStr(classform->opcname);
11008
11009 /* Fetch opfamily information */
11010 familytup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfamilyoid));
11011 if (!HeapTupleIsValid(familytup))
11012 elog(ERROR, "cache lookup failed for operator family %u", opfamilyoid);
11013 familyform = (Form_pg_opfamily) GETSTRUCT(familytup);
11014
11015 opfamilyname = NameStr(familyform->opfname);
11016
11017 /* Fetch all operators and support functions of the opfamily */
11018 oprlist = SearchSysCacheList1(AMOPSTRATEGY, ObjectIdGetDatum(opfamilyoid));
11019 proclist = SearchSysCacheList1(AMPROCNUM, ObjectIdGetDatum(opfamilyoid));
11020=====================================================================
11021Found a 34 line (133 tokens) duplication in the following files:
11022Starting at line 194 of /home/shackle/pggit/postgresql/src/backend/replication/slotfuncs.c
11023Starting at line 1105 of /home/shackle/pggit/postgresql/src/backend/replication/logical/launcher.c
11024Starting at line 3227 of /home/shackle/pggit/postgresql/src/backend/replication/walsender.c
11025
11026 int slotno;
11027
11028 /* check to see if caller supports us returning a tuplestore */
11029 if (rsinfo == NULL || !IsA(rsinfo, ReturnSetInfo))
11030 ereport(ERROR,
11031 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
11032 errmsg("set-valued function called in context that cannot accept a set")));
11033 if (!(rsinfo->allowedModes & SFRM_Materialize))
11034 ereport(ERROR,
11035 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
11036 errmsg("materialize mode required, but it is not " \
11037 "allowed in this context")));
11038
11039 /* Build a tuple descriptor for our result type */
11040 if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
11041 elog(ERROR, "return type must be a row type");
11042
11043 /*
11044 * We don't require any special permission to see this function's data
11045 * because nothing should be sensitive. The most critical being the slot
11046 * name, which shouldn't contain anything particularly sensitive.
11047 */
11048
11049 per_query_ctx = rsinfo->econtext->ecxt_per_query_memory;
11050 oldcontext = MemoryContextSwitchTo(per_query_ctx);
11051
11052 tupstore = tuplestore_begin_heap(true, false, work_mem);
11053 rsinfo->returnMode = SFRM_Materialize;
11054 rsinfo->setResult = tupstore;
11055 rsinfo->setDesc = tupdesc;
11056
11057 MemoryContextSwitchTo(oldcontext);
11058
11059 LWLockAcquire(ReplicationSlotControlLock, LW_SHARED);
11060=====================================================================
11061Found a 39 line (132 tokens) duplication in the following files:
11062Starting at line 122 of /home/shackle/pggit/postgresql/src/bin/scripts/reindexdb.c
11063Starting at line 102 of /home/shackle/pggit/postgresql/src/bin/scripts/clusterdb.c
11064
11065 simple_string_list_append(&indexes, optarg);
11066 break;
11067 case 'v':
11068 verbose = true;
11069 break;
11070 case 2:
11071 maintenance_db = pg_strdup(optarg);
11072 break;
11073 default:
11074 fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
11075 exit(1);
11076 }
11077 }
11078
11079 /*
11080 * Non-option argument specifies database name as long as it wasn't
11081 * already specified with -d / --dbname
11082 */
11083 if (optind < argc && dbname == NULL)
11084 {
11085 dbname = argv[optind];
11086 optind++;
11087 }
11088
11089 if (optind < argc)
11090 {
11091 fprintf(stderr, _("%s: too many command-line arguments (first is \"%s\")\n"),
11092 progname, argv[optind]);
11093 fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
11094 exit(1);
11095 }
11096
11097 setup_cancel_handler();
11098
11099 if (alldb)
11100 {
11101 if (dbname)
11102 {
11103 fprintf(stderr, _("%s: cannot reindex all databases and a specific one at the same time\n"), progname);
11104=====================================================================
11105Found a 3 line (132 tokens) duplication in the following files:
11106Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
11107Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
11108Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
11109
11110 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
11111 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
11112 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
11113=====================================================================
11114Found a 3 line (132 tokens) duplication in the following files:
11115Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
11116Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
11117Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
11118
11119 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
11120 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
11121 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
11122=====================================================================
11123Found a 21 line (132 tokens) duplication in the following files:
11124Starting at line 172 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-array_of_struct.c
11125Starting at line 176 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-pointer_to_struct.c
11126
11127 ECPGt_short,&(inds->phone_ind),(long)1,(long)10,sizeof( struct ind ), ECPGt_EORT);
11128#line 56 "array_of_struct.pgc"
11129
11130if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint();
11131#line 56 "array_of_struct.pgc"
11132
11133if (sqlca.sqlwarn[0] == 'W') sqlprint();
11134#line 56 "array_of_struct.pgc"
11135
11136if (sqlca.sqlcode < 0) sqlprint();}
11137#line 56 "array_of_struct.pgc"
11138
11139 printf("custs1:\n");
11140 for (r = 0; r < 2; r++)
11141 {
11142 printf( "name - %s\n", custs1[r].name.arr );
11143 printf( "phone - %d\n", custs1[r].phone );
11144 }
11145
11146 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select * from customers limit 2", ECPGt_EOIT,
11147 ECPGt_varchar,&(custs2->name),(long)50,(long)10,sizeof( customer2 ),
11148=====================================================================
11149Found a 26 line (132 tokens) duplication in the following files:
11150Starting at line 97 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/utf8_and_iso8859/utf8_and_iso8859.c
11151Starting at line 78 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/utf8_and_win/utf8_and_win.c
11152
11153iso8859_to_utf8(PG_FUNCTION_ARGS)
11154{
11155 int encoding = PG_GETARG_INT32(0);
11156 unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
11157 unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
11158 int len = PG_GETARG_INT32(4);
11159 int i;
11160
11161 CHECK_ENCODING_CONVERSION_ARGS(-1, PG_UTF8);
11162
11163 for (i = 0; i < lengthof(maps); i++)
11164 {
11165 if (encoding == maps[i].encoding)
11166 {
11167 LocalToUtf(src, len, dest,
11168 maps[i].map1,
11169 NULL, 0,
11170 NULL,
11171 encoding);
11172 PG_RETURN_VOID();
11173 }
11174 }
11175
11176 ereport(ERROR,
11177 (errcode(ERRCODE_INTERNAL_ERROR),
11178 errmsg("unexpected encoding ID %d for ISO 8859 character sets",
11179=====================================================================
11180Found a 26 line (132 tokens) duplication in the following files:
11181Starting at line 129 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/utf8_and_iso8859/utf8_and_iso8859.c
11182Starting at line 110 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/utf8_and_win/utf8_and_win.c
11183
11184utf8_to_iso8859(PG_FUNCTION_ARGS)
11185{
11186 int encoding = PG_GETARG_INT32(1);
11187 unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
11188 unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
11189 int len = PG_GETARG_INT32(4);
11190 int i;
11191
11192 CHECK_ENCODING_CONVERSION_ARGS(PG_UTF8, -1);
11193
11194 for (i = 0; i < lengthof(maps); i++)
11195 {
11196 if (encoding == maps[i].encoding)
11197 {
11198 UtfToLocal(src, len, dest,
11199 maps[i].map2,
11200 NULL, 0,
11201 NULL,
11202 encoding);
11203 PG_RETURN_VOID();
11204 }
11205 }
11206
11207 ereport(ERROR,
11208 (errcode(ERRCODE_INTERNAL_ERROR),
11209 errmsg("unexpected encoding ID %d for ISO 8859 character sets",
11210=====================================================================
11211Found a 10 line (132 tokens) duplication in the following files:
11212Starting at line 47 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/latin2_and_win1250/latin2_and_win1250.c
11213Starting at line 67 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/latin2_and_win1250/latin2_and_win1250.c
11214
11215 0xB8, 0xB1, 0xBA, 0x00, 0xA5, 0xBD, 0xB5, 0xBF,
11216 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
11217 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF,
11218 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7,
11219 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF,
11220 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7,
11221 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF,
11222 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7,
11223 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF
11224};
11225=====================================================================
11226Found a 27 line (132 tokens) duplication in the following files:
11227Starting at line 3821 of /home/shackle/pggit/postgresql/src/backend/utils/adt/timestamp.c
11228Starting at line 3955 of /home/shackle/pggit/postgresql/src/backend/utils/adt/timestamp.c
11229
11230 if (timestamp2tm(timestamp, NULL, tm, &fsec, NULL, NULL) != 0)
11231 ereport(ERROR,
11232 (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
11233 errmsg("timestamp out of range")));
11234
11235 switch (val)
11236 {
11237 case DTK_WEEK:
11238 {
11239 int woy;
11240
11241 woy = date2isoweek(tm->tm_year, tm->tm_mon, tm->tm_mday);
11242
11243 /*
11244 * If it is week 52/53 and the month is January, then the
11245 * week must belong to the previous year. Also, some
11246 * December dates belong to the next year.
11247 */
11248 if (woy >= 52 && tm->tm_mon == 1)
11249 --tm->tm_year;
11250 if (woy <= 1 && tm->tm_mon == MONTHS_PER_YEAR)
11251 ++tm->tm_year;
11252 isoweek2date(woy, &(tm->tm_year), &(tm->tm_mon), &(tm->tm_mday));
11253 tm->tm_hour = 0;
11254 tm->tm_min = 0;
11255 tm->tm_sec = 0;
11256 fsec = 0;
11257=====================================================================
11258Found a 27 line (132 tokens) duplication in the following files:
11259Starting at line 2224 of /home/shackle/pggit/postgresql/src/backend/commands/extension.c
11260Starting at line 192 of /home/shackle/pggit/postgresql/src/backend/access/transam/xlogfuncs.c
11261
11262 check_valid_extension_name(NameStr(*extname));
11263
11264 /* check to see if caller supports us returning a tuplestore */
11265 if (rsinfo == NULL || !IsA(rsinfo, ReturnSetInfo))
11266 ereport(ERROR,
11267 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
11268 errmsg("set-valued function called in context that cannot accept a set")));
11269 if (!(rsinfo->allowedModes & SFRM_Materialize))
11270 ereport(ERROR,
11271 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
11272 errmsg("materialize mode required, but it is not " \
11273 "allowed in this context")));
11274
11275 /* Build a tuple descriptor for our result type */
11276 if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
11277 elog(ERROR, "return type must be a row type");
11278
11279 /* Build tuplestore to hold the result rows */
11280 per_query_ctx = rsinfo->econtext->ecxt_per_query_memory;
11281 oldcontext = MemoryContextSwitchTo(per_query_ctx);
11282
11283 tupstore = tuplestore_begin_heap(true, false, work_mem);
11284 rsinfo->returnMode = SFRM_Materialize;
11285 rsinfo->setResult = tupstore;
11286 rsinfo->setDesc = tupdesc;
11287
11288 MemoryContextSwitchTo(oldcontext);
11289=====================================================================
11290Found a 23 line (131 tokens) duplication in the following files:
11291Starting at line 123 of /home/shackle/pggit/postgresql/contrib/btree_gist/btree_enum.c
11292Starting at line 137 of /home/shackle/pggit/postgresql/contrib/btree_gist/btree_oid.c
11293
11294gbt_enum_consistent(PG_FUNCTION_ARGS)
11295{
11296 GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
11297 Oid query = PG_GETARG_OID(1);
11298 StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
11299
11300 /* Oid subtype = PG_GETARG_OID(3); */
11301 bool *recheck = (bool *) PG_GETARG_POINTER(4);
11302 oidKEY *kkk = (oidKEY *) DatumGetPointer(entry->key);
11303 GBT_NUMKEY_R key;
11304
11305 /* All cases served by this function are exact */
11306 *recheck = false;
11307
11308 key.lower = (GBT_NUMKEY *) &kkk->lower;
11309 key.upper = (GBT_NUMKEY *) &kkk->upper;
11310
11311 PG_RETURN_BOOL(
11312 gbt_num_consistent(&key, (void *) &query, &strategy, GIST_LEAF(entry), &tinfo, fcinfo->flinfo)
11313 );
11314}
11315
11316Datum
11317=====================================================================
11318Found a 26 line (131 tokens) duplication in the following files:
11319Starting at line 50 of /home/shackle/pggit/postgresql/src/common/base64.c
11320Starting at line 221 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
11321
11322 char *p;
11323 const char *s,
11324 *end = src + len;
11325 int pos = 2;
11326 uint32 buf = 0;
11327
11328 s = src;
11329 p = dst;
11330
11331 while (s < end)
11332 {
11333 buf |= (unsigned char) *s << (pos << 3);
11334 pos--;
11335 s++;
11336
11337 /* write it out */
11338 if (pos < 0)
11339 {
11340 *p++ = _base64[(buf >> 18) & 0x3f];
11341 *p++ = _base64[(buf >> 12) & 0x3f];
11342 *p++ = _base64[(buf >> 6) & 0x3f];
11343 *p++ = _base64[buf & 0x3f];
11344
11345 pos = 2;
11346 buf = 0;
11347 }
11348=====================================================================
11349Found a 15 line (131 tokens) duplication in the following files:
11350Starting at line 216 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
11351Starting at line 356 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
11352Starting at line 524 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
11353Starting at line 694 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
11354
11355 ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
11356 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
11357 ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
11358 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
11359 ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
11360 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
11361#line 74 "cursor.pgc"
11362
11363if (sqlca.sqlcode < 0) exit (1);}
11364#line 74 "cursor.pgc"
11365
11366 printf("%d %s\n", id, t);
11367
11368 strcpy(msg, "fetch 1 from");
11369 { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch 1 from $0",
11370=====================================================================
11371Found a 15 line (131 tokens) duplication in the following files:
11372Starting at line 292 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
11373Starting at line 436 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
11374Starting at line 600 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
11375Starting at line 770 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
11376
11377 ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
11378 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
11379 ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
11380 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
11381 ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
11382 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
11383#line 95 "cursor.pgc"
11384
11385if (sqlca.sqlcode < 0) exit (1);}
11386#line 95 "cursor.pgc"
11387
11388 printf("%d %s\n", id, t);
11389
11390 strcpy(msg, "close");
11391 { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "close $0",
11392=====================================================================
11393Found a 15 line (131 tokens) duplication in the following files:
11394Starting at line 341 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
11395Starting at line 679 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
11396
11397 ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
11398 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
11399 ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
11400 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
11401 ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
11402 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
11403#line 111 "cursor.pgc"
11404
11405if (sqlca.sqlcode < 0) exit (1);}
11406#line 111 "cursor.pgc"
11407
11408 printf("%d %s\n", id, t);
11409
11410 strcpy(msg, "fetch");
11411 { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0",
11412=====================================================================
11413Found a 15 line (131 tokens) duplication in the following files:
11414Starting at line 389 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
11415Starting at line 557 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
11416Starting at line 727 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
11417
11418 ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
11419 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
11420 ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
11421 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
11422 ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
11423 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
11424#line 124 "cursor.pgc"
11425
11426if (sqlca.sqlcode < 0) exit (1);}
11427#line 124 "cursor.pgc"
11428
11429 printf("%d %s\n", id, t);
11430
11431 strcpy(msg, "move");
11432 { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "move absolute 0 $0",
11433=====================================================================
11434Found a 26 line (131 tokens) duplication in the following files:
11435Starting at line 552 of /home/shackle/pggit/postgresql/src/backend/utils/adt/pgstatfuncs.c
11436Starting at line 1891 of /home/shackle/pggit/postgresql/src/backend/commands/extension.c
11437Starting at line 2000 of /home/shackle/pggit/postgresql/src/backend/commands/extension.c
11438Starting at line 2224 of /home/shackle/pggit/postgresql/src/backend/commands/extension.c
11439Starting at line 192 of /home/shackle/pggit/postgresql/src/backend/access/transam/xlogfuncs.c
11440Starting at line 194 of /home/shackle/pggit/postgresql/src/backend/replication/slotfuncs.c
11441Starting at line 1105 of /home/shackle/pggit/postgresql/src/backend/replication/logical/launcher.c
11442Starting at line 3227 of /home/shackle/pggit/postgresql/src/backend/replication/walsender.c
11443
11444 MemoryContext oldcontext;
11445
11446 /* check to see if caller supports us returning a tuplestore */
11447 if (rsinfo == NULL || !IsA(rsinfo, ReturnSetInfo))
11448 ereport(ERROR,
11449 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
11450 errmsg("set-valued function called in context that cannot accept a set")));
11451 if (!(rsinfo->allowedModes & SFRM_Materialize))
11452 ereport(ERROR,
11453 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
11454 errmsg("materialize mode required, but it is not " \
11455 "allowed in this context")));
11456
11457 /* Build a tuple descriptor for our result type */
11458 if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
11459 elog(ERROR, "return type must be a row type");
11460
11461 per_query_ctx = rsinfo->econtext->ecxt_per_query_memory;
11462 oldcontext = MemoryContextSwitchTo(per_query_ctx);
11463
11464 tupstore = tuplestore_begin_heap(true, false, work_mem);
11465 rsinfo->returnMode = SFRM_Materialize;
11466 rsinfo->setResult = tupstore;
11467 rsinfo->setDesc = tupdesc;
11468
11469 MemoryContextSwitchTo(oldcontext);
11470=====================================================================
11471Found a 28 line (131 tokens) duplication in the following files:
11472Starting at line 4034 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
11473Starting at line 4066 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
11474
11475 *str++ = '/';
11476 str = pg_ltostr_zeropad(str,
11477 (tm->tm_year > 0) ? tm->tm_year : -(tm->tm_year - 1), 4);
11478 *str++ = ' ';
11479 str = pg_ltostr_zeropad(str, tm->tm_hour, 2);
11480 *str++ = ':';
11481 str = pg_ltostr_zeropad(str, tm->tm_min, 2);
11482 *str++ = ':';
11483 str = AppendTimestampSeconds(str, tm, fsec);
11484
11485 /*
11486 * Note: the uses of %.*s in this function would be risky if the
11487 * timezone names ever contain non-ASCII characters. However, all
11488 * TZ abbreviations in the IANA database are plain ASCII.
11489 */
11490 if (print_tz)
11491 {
11492 if (tzn)
11493 {
11494 sprintf(str, " %.*s", MAXTZLEN, tzn);
11495 str += strlen(str);
11496 }
11497 else
11498 str = EncodeTimezone(str, tz, style);
11499 }
11500 break;
11501
11502 case USE_GERMAN_DATES:
11503=====================================================================
11504Found a 34 line (131 tokens) duplication in the following files:
11505Starting at line 3240 of /home/shackle/pggit/postgresql/src/backend/commands/typecmds.c
11506Starting at line 3322 of /home/shackle/pggit/postgresql/src/backend/commands/typecmds.c
11507
11508 if (stmt->renameType == OBJECT_DOMAIN && typTup->typtype != TYPTYPE_DOMAIN)
11509 ereport(ERROR,
11510 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
11511 errmsg("%s is not a domain",
11512 format_type_be(typeOid))));
11513
11514 /*
11515 * If it's a composite type, we need to check that it really is a
11516 * free-standing composite type, and not a table's rowtype. We want people
11517 * to use ALTER TABLE not ALTER TYPE for that case.
11518 */
11519 if (typTup->typtype == TYPTYPE_COMPOSITE &&
11520 get_rel_relkind(typTup->typrelid) != RELKIND_COMPOSITE_TYPE)
11521 ereport(ERROR,
11522 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
11523 errmsg("%s is a table's row type",
11524 format_type_be(typeOid)),
11525 errhint("Use ALTER TABLE instead.")));
11526
11527 /* don't allow direct alteration of array types, either */
11528 if (OidIsValid(typTup->typelem) &&
11529 get_array_type(typTup->typelem) == typeOid)
11530 ereport(ERROR,
11531 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
11532 errmsg("cannot alter array type %s",
11533 format_type_be(typeOid)),
11534 errhint("You can alter type %s, which will alter the array type as well.",
11535 format_type_be(typTup->typelem))));
11536
11537 /*
11538 * If type is composite we need to rename associated pg_class entry too.
11539 * RenameRelationInternal will call RenameTypeInternal automatically.
11540 */
11541 if (typTup->typtype == TYPTYPE_COMPOSITE)
11542=====================================================================
11543Found a 5 line (130 tokens) duplication in the following files:
11544Starting at line 74 of /home/shackle/pggit/postgresql/contrib/pgcrypto/crypt-des.c
11545Starting at line 334 of /home/shackle/pggit/postgresql/src/port/crypt.c
11546
11547static uint8 IP[64] = {
11548 58, 50, 42, 34, 26, 18, 10, 2, 60, 52, 44, 36, 28, 20, 12, 4,
11549 62, 54, 46, 38, 30, 22, 14, 6, 64, 56, 48, 40, 32, 24, 16, 8,
11550 57, 49, 41, 33, 25, 17, 9, 1, 59, 51, 43, 35, 27, 19, 11, 3,
11551 61, 53, 45, 37, 29, 21, 13, 5, 63, 55, 47, 39, 31, 23, 15, 7
11552=====================================================================
11553Found a 14 line (130 tokens) duplication in the following files:
11554Starting at line 201 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
11555Starting at line 356 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
11556Starting at line 371 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
11557Starting at line 389 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
11558Starting at line 418 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
11559Starting at line 436 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
11560Starting at line 509 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
11561Starting at line 524 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
11562Starting at line 539 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
11563Starting at line 557 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
11564Starting at line 582 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
11565Starting at line 600 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
11566
11567 ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
11568 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
11569 ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
11570 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
11571 ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
11572 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
11573#line 70 "cursor.pgc"
11574
11575if (sqlca.sqlcode < 0) exit (1);}
11576#line 70 "cursor.pgc"
11577
11578 printf("%d %s\n", id, t);
11579
11580 strcpy(msg, "fetch");
11581=====================================================================
11582Found a 14 line (130 tokens) duplication in the following files:
11583Starting at line 216 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
11584Starting at line 231 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
11585Starting at line 249 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
11586Starting at line 274 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
11587Starting at line 292 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
11588Starting at line 341 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
11589
11590 ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
11591 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
11592 ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
11593 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
11594 ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
11595 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
11596#line 74 "cursor.pgc"
11597
11598if (sqlca.sqlcode < 0) exit (1);}
11599#line 74 "cursor.pgc"
11600
11601 printf("%d %s\n", id, t);
11602
11603 strcpy(msg, "fetch 1 from");
11604=====================================================================
11605Found a 5 line (129 tokens) duplication in the following files:
11606Starting at line 31 of /home/shackle/pggit/postgresql/contrib/ltree/_ltree_gist.c
11607Starting at line 51 of /home/shackle/pggit/postgresql/contrib/pg_trgm/trgm_gist.c
11608Starting at line 32 of /home/shackle/pggit/postgresql/contrib/intarray/_intbig_gist.c
11609Starting at line 117 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
11610Starting at line 82 of /home/shackle/pggit/postgresql/src/backend/utils/adt/tsgistidx.c
11611
11612 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
11613 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
11614 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
11615 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
11616 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
11617=====================================================================
11618Found a 5 line (129 tokens) duplication in the following files:
11619Starting at line 35 of /home/shackle/pggit/postgresql/contrib/ltree/_ltree_gist.c
11620Starting at line 47 of /home/shackle/pggit/postgresql/contrib/pg_trgm/trgm_gist.c
11621Starting at line 28 of /home/shackle/pggit/postgresql/contrib/intarray/_intbig_gist.c
11622Starting at line 113 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
11623Starting at line 78 of /home/shackle/pggit/postgresql/src/backend/utils/adt/tsgistidx.c
11624
11625 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
11626 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
11627 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
11628 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
11629 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
11630=====================================================================
11631Found a 32 line (129 tokens) duplication in the following files:
11632Starting at line 6947 of /home/shackle/pggit/postgresql/src/pl/plpgsql/src/pl_exec.c
11633Starting at line 7056 of /home/shackle/pggit/postgresql/src/pl/plpgsql/src/pl_exec.c
11634
11635 while (anum < td_natts &&
11636 TupleDescAttr(tupdesc, anum)->attisdropped)
11637 anum++; /* skip dropped column in tuple */
11638
11639 if (anum < td_natts)
11640 {
11641 value = values[anum];
11642 isnull = nulls[anum];
11643 valtype = TupleDescAttr(tupdesc, anum)->atttypid;
11644 valtypmod = TupleDescAttr(tupdesc, anum)->atttypmod;
11645 anum++;
11646 }
11647 else
11648 {
11649 /* no source for destination column */
11650 value = (Datum) 0;
11651 isnull = true;
11652 valtype = UNKNOWNOID;
11653 valtypmod = -1;
11654
11655 /* When source value is missing */
11656 if (strict_multiassignment_level)
11657 ereport(strict_multiassignment_level,
11658 (errcode(ERRCODE_DATATYPE_MISMATCH),
11659 errmsg("number of source and target fields in assignment do not match"),
11660 /* translator: %s represents a name of an extra check */
11661 errdetail("%s check of %s is active.",
11662 "strict_multi_assignment",
11663 strict_multiassignment_level == ERROR ? "extra_errors" :
11664 "extra_warnings"),
11665 errhint("Make sure the query returns the exact list of columns.")));
11666 }
11667=====================================================================
11668Found a 25 line (129 tokens) duplication in the following files:
11669Starting at line 1361 of /home/shackle/pggit/postgresql/src/pl/plpython/plpy_typeio.c
11670Starting at line 1501 of /home/shackle/pggit/postgresql/src/pl/plpython/plpy_typeio.c
11671
11672 Assert(PyMapping_Check(mapping));
11673
11674 /* Build tuple */
11675 values = palloc(sizeof(Datum) * desc->natts);
11676 nulls = palloc(sizeof(bool) * desc->natts);
11677 for (i = 0; i < desc->natts; ++i)
11678 {
11679 char *key;
11680 PyObject *volatile value;
11681 PLyObToDatum *att;
11682 Form_pg_attribute attr = TupleDescAttr(desc, i);
11683
11684 if (attr->attisdropped)
11685 {
11686 values[i] = (Datum) 0;
11687 nulls[i] = true;
11688 continue;
11689 }
11690
11691 key = NameStr(attr->attname);
11692 value = NULL;
11693 att = &arg->u.tuple.atts[i];
11694 PG_TRY();
11695 {
11696 value = PyMapping_GetItemString(mapping, key);
11697=====================================================================
11698Found a 3 line (129 tokens) duplication in the following files:
11699Starting at line 31 of /home/shackle/pggit/postgresql/src/common/base64.c
11700Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
11701Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
11702Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
11703Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
11704Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
11705Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
11706Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
11707Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
11708Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
11709Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
11710Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
11711Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
11712Starting at line 207 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
11713Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
11714Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
11715Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
11716Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
11717Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
11718Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
11719
11720 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
11721 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
11722 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
11723=====================================================================
11724Found a 9 line (129 tokens) duplication in the following files:
11725Starting at line 203 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-array.c
11726Starting at line 298 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-array.c
11727
11728 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test ( f , i , a , text , ts , n , d , inter ) values ( 404.90 , 3 , '{0,1,2,3,4,5,6,7,8,9}' , 'abcdefghij' , $1 , $2 , $3 , $4 )",
11729 ECPGt_timestamp,&(ts),(long)1,(long)10,sizeof(timestamp),
11730 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
11731 ECPGt_numeric,&(n),(long)1,(long)10,sizeof(numeric),
11732 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
11733 ECPGt_date,&(d),(long)1,(long)10,sizeof(date),
11734 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
11735 ECPGt_interval,&(in),(long)1,(long)10,sizeof(interval),
11736 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
11737=====================================================================
11738Found a 33 line (129 tokens) duplication in the following files:
11739Starting at line 31 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/connect-test2.c
11740Starting at line 30 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/connect-test3.c
11741
11742int
11743main(void)
11744{
11745/* exec sql begin declare section */
11746
11747
11748
11749#line 17 "test2.pgc"
11750 char id [ 200 ] ;
11751
11752#line 18 "test2.pgc"
11753 char res [ 200 ] ;
11754/* exec sql end declare section */
11755#line 19 "test2.pgc"
11756
11757
11758 ECPGdebug(1, stderr);
11759
11760 strcpy(id, "first");
11761 { ECPGconnect(__LINE__, 0, "ecpg2_regression" , NULL, NULL , id, 0); }
11762#line 24 "test2.pgc"
11763
11764 { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , "second", 0); }
11765#line 25 "test2.pgc"
11766
11767
11768 /* this selects from "second" which was opened last */
11769 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select current_database ( )", ECPGt_EOIT,
11770 ECPGt_char,(res),(long)200,(long)1,(200)*sizeof(char),
11771 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
11772#line 28 "test2.pgc"
11773
11774 { ECPGdo(__LINE__, 0, 1, "first", 0, ECPGst_normal, "select current_database ( )", ECPGt_EOIT,
11775=====================================================================
11776Found a 21 line (129 tokens) duplication in the following files:
11777Starting at line 74 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/connect-test2.c
11778Starting at line 52 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/connect-test3.c
11779
11780 { ECPGsetconn(__LINE__, "first");}
11781#line 32 "test2.pgc"
11782
11783 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select current_database ( )", ECPGt_EOIT,
11784 ECPGt_char,(res),(long)200,(long)1,(200)*sizeof(char),
11785 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
11786#line 33 "test2.pgc"
11787
11788
11789 /* this will disconnect from "first" */
11790 { ECPGdisconnect(__LINE__, "CURRENT");}
11791#line 36 "test2.pgc"
11792
11793 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select current_database ( )", ECPGt_EOIT,
11794 ECPGt_char,(res),(long)200,(long)1,(200)*sizeof(char),
11795 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
11796#line 37 "test2.pgc"
11797
11798
11799 /* error here since "first" is already disconnected */
11800 { ECPGdisconnect(__LINE__, id);}
11801=====================================================================
11802Found a 15 line (129 tokens) duplication in the following files:
11803Starting at line 201 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
11804Starting at line 679 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
11805
11806 ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
11807 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
11808 ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
11809 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
11810 ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
11811 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
11812#line 70 "cursor.pgc"
11813
11814if (sqlca.sqlcode < 0) exit (1);}
11815#line 70 "cursor.pgc"
11816
11817 printf("%d %s\n", id, t);
11818
11819 strcpy(msg, "fetch");
11820 { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch forward $0",
11821=====================================================================
11822Found a 32 line (129 tokens) duplication in the following files:
11823Starting at line 372 of /home/shackle/pggit/postgresql/src/backend/tsearch/ts_parse.c
11824Starting at line 548 of /home/shackle/pggit/postgresql/src/backend/tsearch/ts_parse.c
11825
11826 prsdata = (void *) DatumGetPointer(FunctionCall2(&prsobj->prsstart,
11827 PointerGetDatum(buf),
11828 Int32GetDatum(buflen)));
11829
11830 LexizeInit(&ldata, cfg);
11831
11832 do
11833 {
11834 type = DatumGetInt32(FunctionCall3(&(prsobj->prstoken),
11835 PointerGetDatum(prsdata),
11836 PointerGetDatum(&lemm),
11837 PointerGetDatum(&lenlemm)));
11838
11839 if (type > 0 && lenlemm >= MAXSTRLEN)
11840 {
11841#ifdef IGNORE_LONGLEXEME
11842 ereport(NOTICE,
11843 (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
11844 errmsg("word is too long to be indexed"),
11845 errdetail("Words longer than %d characters are ignored.",
11846 MAXSTRLEN)));
11847 continue;
11848#else
11849 ereport(ERROR,
11850 (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
11851 errmsg("word is too long to be indexed"),
11852 errdetail("Words longer than %d characters are ignored.",
11853 MAXSTRLEN)));
11854#endif
11855 }
11856
11857 LexizeAddLemm(&ldata, type, lemm, lenlemm);
11858=====================================================================
11859Found a 11 line (129 tokens) duplication in the following files:
11860Starting at line 1737 of /home/shackle/pggit/postgresql/src/backend/utils/mb/wchar.c
11861Starting at line 1755 of /home/shackle/pggit/postgresql/src/backend/utils/mb/wchar.c
11862
11863 {pg_mule2wchar_with_len, pg_wchar2mule_with_len, pg_mule_mblen, pg_mule_dsplen, pg_mule_verifier, 4}, /* PG_MULE_INTERNAL */
11864 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN1 */
11865 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN2 */
11866 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN3 */
11867 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN4 */
11868 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN5 */
11869 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN6 */
11870 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN7 */
11871 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN8 */
11872 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN9 */
11873 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN10 */
11874=====================================================================
11875Found a 39 line (129 tokens) duplication in the following files:
11876Starting at line 84 of /home/shackle/pggit/postgresql/src/backend/commands/seclabel.c
11877Starting at line 64 of /home/shackle/pggit/postgresql/src/backend/commands/comment.c
11878
11879 }
11880
11881 /*
11882 * Translate the parser representation which identifies this object into
11883 * an ObjectAddress. get_object_address() will throw an error if the
11884 * object does not exist, and will also acquire a lock on the target to
11885 * guard against concurrent modifications.
11886 */
11887 address = get_object_address(stmt->objtype, stmt->object,
11888 &relation, ShareUpdateExclusiveLock, false);
11889
11890 /* Require ownership of the target object. */
11891 check_object_ownership(GetUserId(), stmt->objtype, address,
11892 stmt->object, relation);
11893
11894 /* Perform other integrity checks as needed. */
11895 switch (stmt->objtype)
11896 {
11897 case OBJECT_COLUMN:
11898
11899 /*
11900 * Allow security labels only on columns of tables, views,
11901 * materialized views, composite types, and foreign tables (which
11902 * are the only relkinds for which pg_dump will dump labels).
11903 */
11904 if (relation->rd_rel->relkind != RELKIND_RELATION &&
11905 relation->rd_rel->relkind != RELKIND_VIEW &&
11906 relation->rd_rel->relkind != RELKIND_MATVIEW &&
11907 relation->rd_rel->relkind != RELKIND_COMPOSITE_TYPE &&
11908 relation->rd_rel->relkind != RELKIND_FOREIGN_TABLE &&
11909 relation->rd_rel->relkind != RELKIND_PARTITIONED_TABLE)
11910 ereport(ERROR,
11911 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
11912 errmsg("\"%s\" is not a table, view, materialized view, composite type, or foreign table",
11913 RelationGetRelationName(relation))));
11914 break;
11915 default:
11916 break;
11917 }
11918=====================================================================
11919Found a 13 line (128 tokens) duplication in the following files:
11920Starting at line 41 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_backup_custom.c
11921Starting at line 71 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_backup_directory.c
11922
11923static void _EndData(ArchiveHandle *AH, TocEntry *te);
11924static int _WriteByte(ArchiveHandle *AH, const int i);
11925static int _ReadByte(ArchiveHandle *);
11926static void _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len);
11927static void _ReadBuf(ArchiveHandle *AH, void *buf, size_t len);
11928static void _CloseArchive(ArchiveHandle *AH);
11929static void _ReopenArchive(ArchiveHandle *AH);
11930static void _PrintTocData(ArchiveHandle *AH, TocEntry *te);
11931static void _WriteExtraToc(ArchiveHandle *AH, TocEntry *te);
11932static void _ReadExtraToc(ArchiveHandle *AH, TocEntry *te);
11933static void _PrintExtraToc(ArchiveHandle *AH, TocEntry *te);
11934
11935static void _PrintData(ArchiveHandle *AH);
11936=====================================================================
11937Found a 37 line (128 tokens) duplication in the following files:
11938Starting at line 1846 of /home/shackle/pggit/postgresql/src/backend/executor/execMain.c
11939Starting at line 1979 of /home/shackle/pggit/postgresql/src/backend/executor/execMain.c
11940
11941 Bitmapset *updatedCols;
11942
11943 /*
11944 * Need to first convert the tuple to the root partitioned table's row
11945 * type. For details, check similar comments in ExecConstraints().
11946 */
11947 if (resultRelInfo->ri_PartitionRoot)
11948 {
11949 TupleDesc old_tupdesc = RelationGetDescr(rel);
11950 AttrNumber *map;
11951
11952 rel = resultRelInfo->ri_PartitionRoot;
11953 tupdesc = RelationGetDescr(rel);
11954 /* a reverse map */
11955 map = convert_tuples_by_name_map_if_req(old_tupdesc, tupdesc,
11956 gettext_noop("could not convert row type"));
11957
11958 /*
11959 * Partition-specific slot's tupdesc can't be changed, so allocate a
11960 * new one.
11961 */
11962 if (map != NULL)
11963 slot = execute_attr_map_slot(map, slot,
11964 MakeTupleTableSlot(tupdesc, &TTSOpsVirtual));
11965 }
11966
11967 insertedCols = GetInsertedColumns(resultRelInfo, estate);
11968 updatedCols = GetUpdatedColumns(resultRelInfo, estate);
11969 modifiedCols = bms_union(insertedCols, updatedCols);
11970 val_desc = ExecBuildSlotValueDescription(RelationGetRelid(rel),
11971 slot,
11972 tupdesc,
11973 modifiedCols,
11974 64);
11975 ereport(ERROR,
11976 (errcode(ERRCODE_CHECK_VIOLATION),
11977 errmsg("new row for relation \"%s\" violates partition constraint",
11978=====================================================================
11979Found a 5 line (128 tokens) duplication in the following files:
11980Starting at line 98 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
11981Starting at line 102 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
11982
11983 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
11984 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
11985 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
11986 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
11987 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
11988=====================================================================
11989Found a 9 line (128 tokens) duplication in the following files:
11990Starting at line 69 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/cyrillic_and_mic/cyrillic_and_mic.c
11991Starting at line 111 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/cyrillic_and_mic/cyrillic_and_mic.c
11992
11993 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11994 0xE1, 0xE2, 0xF7, 0xE7, 0xE4, 0xE5, 0xF6, 0xFA,
11995 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xF0,
11996 0xF2, 0xF3, 0xF4, 0xF5, 0xE6, 0xE8, 0xE3, 0xFE,
11997 0xFB, 0xFD, 0xFF, 0xF9, 0xF8, 0xFC, 0xE0, 0xF1,
11998 0xC1, 0xC2, 0xD7, 0xC7, 0xC4, 0xC5, 0xD6, 0xDA,
11999 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0,
12000 0xD2, 0xD3, 0xD4, 0xD5, 0xC6, 0xC8, 0xC3, 0xDE,
12001 0xDB, 0xDD, 0xDF, 0xD9, 0xD8, 0xDC, 0xC0, 0xD1,
12002=====================================================================
12003Found a 9 line (128 tokens) duplication in the following files:
12004Starting at line 211 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/cyrillic_and_mic/cyrillic_and_mic.c
12005Starting at line 269 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/cyrillic_and_mic/cyrillic_and_mic.c
12006
12007 0xF1, 0x00, 0xF3, 0x00, 0x00, 0x00, 0x00, 0xF5,
12008 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
12009 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F,
12010 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
12011 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F,
12012 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7,
12013 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF,
12014 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7,
12015 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF
12016=====================================================================
12017Found a 9 line (128 tokens) duplication in the following files:
12018Starting at line 229 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/cyrillic_and_mic/cyrillic_and_mic.c
12019Starting at line 47 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/latin2_and_win1250/latin2_and_win1250.c
12020Starting at line 67 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/latin2_and_win1250/latin2_and_win1250.c
12021
12022 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
12023 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
12024 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF,
12025 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7,
12026 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF,
12027 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7,
12028 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF,
12029 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7,
12030 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF,
12031=====================================================================
12032Found a 62 line (128 tokens) duplication in the following files:
12033Starting at line 613 of /home/shackle/pggit/postgresql/src/backend/access/nbtree/nbtxlog.c
12034Starting at line 1061 of /home/shackle/pggit/postgresql/src/backend/access/hash/hash_xlog.c
12035
12036 LockBuffer(hbuffer, BT_READ);
12037 hpage = (Page) BufferGetPage(hbuffer);
12038
12039 /*
12040 * Look up the heap tuple header that the index tuple points at by
12041 * using the heap node supplied with the xlrec. We can't use
12042 * heap_fetch, since it uses ReadBuffer rather than XLogReadBuffer.
12043 * Note that we are not looking at tuple data here, just headers.
12044 */
12045 hoffnum = ItemPointerGetOffsetNumber(&(itup->t_tid));
12046 hitemid = PageGetItemId(hpage, hoffnum);
12047
12048 /*
12049 * Follow any redirections until we find something useful.
12050 */
12051 while (ItemIdIsRedirected(hitemid))
12052 {
12053 hoffnum = ItemIdGetRedirect(hitemid);
12054 hitemid = PageGetItemId(hpage, hoffnum);
12055 CHECK_FOR_INTERRUPTS();
12056 }
12057
12058 /*
12059 * If the heap item has storage, then read the header and use that to
12060 * set latestRemovedXid.
12061 *
12062 * Some LP_DEAD items may not be accessible, so we ignore them.
12063 */
12064 if (ItemIdHasStorage(hitemid))
12065 {
12066 htuphdr = (HeapTupleHeader) PageGetItem(hpage, hitemid);
12067
12068 HeapTupleHeaderAdvanceLatestRemovedXid(htuphdr, &latestRemovedXid);
12069 }
12070 else if (ItemIdIsDead(hitemid))
12071 {
12072 /*
12073 * Conjecture: if hitemid is dead then it had xids before the xids
12074 * marked on LP_NORMAL items. So we just ignore this item and move
12075 * onto the next, for the purposes of calculating
12076 * latestRemovedxids.
12077 */
12078 }
12079 else
12080 Assert(!ItemIdIsUsed(hitemid));
12081
12082 UnlockReleaseBuffer(hbuffer);
12083 }
12084
12085 UnlockReleaseBuffer(ibuffer);
12086
12087 /*
12088 * If all heap tuples were LP_DEAD then we will be returning
12089 * InvalidTransactionId here, which avoids conflicts. This matches
12090 * existing logic which assumes that LP_DEAD tuples must already be older
12091 * than the latestRemovedXid on the cleanup record that set them as
12092 * LP_DEAD, hence must already have generated a conflict.
12093 */
12094 return latestRemovedXid;
12095}
12096
12097static void
12098=====================================================================
12099Found a 4 line (128 tokens) duplication in the following files:
12100Starting at line 138 of /home/shackle/pggit/postgresql/src/backend/access/heap/visibilitymap.c
12101Starting at line 142 of /home/shackle/pggit/postgresql/src/backend/access/heap/visibilitymap.c
12102
12103 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 2, 2, 1, 1, 2, 2,
12104 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 2, 2, 1, 1, 2, 2,
12105 1, 1, 2, 2, 1, 1, 2, 2, 2, 2, 3, 3, 2, 2, 3, 3,
12106 1, 1, 2, 2, 1, 1, 2, 2, 2, 2, 3, 3, 2, 2, 3, 3,
12107=====================================================================
12108Found a 5 line (128 tokens) duplication in the following files:
12109Starting at line 145 of /home/shackle/pggit/postgresql/src/backend/access/heap/visibilitymap.c
12110Starting at line 149 of /home/shackle/pggit/postgresql/src/backend/access/heap/visibilitymap.c
12111
12112 1, 1, 2, 2, 1, 1, 2, 2, 2, 2, 3, 3, 2, 2, 3, 3,
12113 1, 1, 2, 2, 1, 1, 2, 2, 2, 2, 3, 3, 2, 2, 3, 3,
12114 1, 1, 2, 2, 1, 1, 2, 2, 2, 2, 3, 3, 2, 2, 3, 3,
12115 2, 2, 3, 3, 2, 2, 3, 3, 3, 3, 4, 4, 3, 3, 4, 4,
12116 2, 2, 3, 3, 2, 2, 3, 3, 3, 3, 4, 4, 3, 3, 4, 4,
12117=====================================================================
12118Found a 31 line (127 tokens) duplication in the following files:
12119Starting at line 258 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-array_of_struct.c
12120Starting at line 262 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-pointer_to_struct.c
12121
12122 ECPGt_varchar,(onlyname),(long)50,(long)2,sizeof(struct varchar_5),
12123 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
12124#line 85 "array_of_struct.pgc"
12125
12126if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint();
12127#line 85 "array_of_struct.pgc"
12128
12129if (sqlca.sqlwarn[0] == 'W') sqlprint();
12130#line 85 "array_of_struct.pgc"
12131
12132if (sqlca.sqlcode < 0) sqlprint();}
12133#line 85 "array_of_struct.pgc"
12134
12135 printf("\nname:\n");
12136 for (r = 0; r < 2; r++)
12137 {
12138 printf( "name - %s\n", onlyname[r].arr );
12139 }
12140
12141 { ECPGdisconnect(__LINE__, "ALL");
12142#line 92 "array_of_struct.pgc"
12143
12144if (sqlca.sqlwarn[0] == 'W') sqlprint();
12145#line 92 "array_of_struct.pgc"
12146
12147if (sqlca.sqlcode < 0) sqlprint();}
12148#line 92 "array_of_struct.pgc"
12149
12150
12151 return 0;
12152}
12153=====================================================================
12154Found a 19 line (127 tokens) duplication in the following files:
12155Starting at line 387 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/compat_informix-describe.c
12156Starting at line 385 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-describe.c
12157Starting at line 217 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-describe.c
12158Starting at line 379 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-describe.c
12159
12160 count1 == sqlda3->sqld))
12161 exit(1);
12162
12163 for (i = 1; i <= count1; i++)
12164 {
12165 { ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
12166 ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
12167
12168#line 168 "describe.pgc"
12169
12170if (sqlca.sqlcode < 0) exit (1);}
12171#line 168 "describe.pgc"
12172
12173 { ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
12174 ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
12175
12176#line 169 "describe.pgc"
12177
12178if (sqlca.sqlcode < 0) exit (1);}
12179=====================================================================
12180Found a 14 line (127 tokens) duplication in the following files:
12181Starting at line 326 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
12182Starting at line 403 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
12183
12184 { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "declare $0 cursor for select id , t from t1",
12185 ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
12186 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
12187 ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
12188 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
12189 ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
12190 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
12191#line 108 "cursor.pgc"
12192
12193if (sqlca.sqlcode < 0) exit (1);}
12194#line 108 "cursor.pgc"
12195
12196
12197 strcpy(msg, "fetch from");
12198=====================================================================
12199Found a 4 line (127 tokens) duplication in the following files:
12200Starting at line 72 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
12201Starting at line 76 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
12202Starting at line 80 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
12203
12204 0, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
12205 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
12206 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
12207 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
12208=====================================================================
12209Found a 21 line (126 tokens) duplication in the following files:
12210Starting at line 62 of /home/shackle/pggit/postgresql/contrib/bloom/blvalidate.c
12211Starting at line 65 of /home/shackle/pggit/postgresql/src/backend/access/brin/brin_validate.c
12212Starting at line 65 of /home/shackle/pggit/postgresql/src/backend/access/nbtree/nbtvalidate.c
12213Starting at line 63 of /home/shackle/pggit/postgresql/src/backend/access/gin/ginvalidate.c
12214Starting at line 63 of /home/shackle/pggit/postgresql/src/backend/access/gist/gistvalidate.c
12215
12216 opckeytype = opcintype;
12217 opclassname = NameStr(classform->opcname);
12218
12219 /* Fetch opfamily information */
12220 familytup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfamilyoid));
12221 if (!HeapTupleIsValid(familytup))
12222 elog(ERROR, "cache lookup failed for operator family %u", opfamilyoid);
12223 familyform = (Form_pg_opfamily) GETSTRUCT(familytup);
12224
12225 opfamilyname = NameStr(familyform->opfname);
12226
12227 /* Fetch all operators and support functions of the opfamily */
12228 oprlist = SearchSysCacheList1(AMOPSTRATEGY, ObjectIdGetDatum(opfamilyoid));
12229 proclist = SearchSysCacheList1(AMPROCNUM, ObjectIdGetDatum(opfamilyoid));
12230
12231 /* Check individual support functions */
12232 for (i = 0; i < proclist->n_members; i++)
12233 {
12234 HeapTuple proctup = &proclist->members[i]->tuple;
12235 Form_pg_amproc procform = (Form_pg_amproc) GETSTRUCT(proctup);
12236 bool ok;
12237=====================================================================
12238Found a 3 line (126 tokens) duplication in the following files:
12239Starting at line 31 of /home/shackle/pggit/postgresql/src/common/base64.c
12240Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
12241Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
12242Starting at line 207 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
12243Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
12244
12245 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
12246 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
12247 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
12248=====================================================================
12249Found a 3 line (126 tokens) duplication in the following files:
12250Starting at line 31 of /home/shackle/pggit/postgresql/src/common/base64.c
12251Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
12252Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
12253Starting at line 207 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
12254Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
12255
12256 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
12257 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
12258 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
12259=====================================================================
12260Found a 19 line (126 tokens) duplication in the following files:
12261Starting at line 84 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-desc.c
12262Starting at line 210 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-desc.c
12263
12264 { ECPGset_desc(__LINE__, "indesc", 1,ECPGd_data,
12265 ECPGt_int,&(val1),(long)1,(long)1,sizeof(int), ECPGd_EODT);
12266
12267#line 25 "desc.pgc"
12268
12269if (sqlca.sqlcode < 0) sqlprint();}
12270#line 25 "desc.pgc"
12271
12272 { ECPGset_desc(__LINE__, "indesc", 2,ECPGd_data,
12273 ECPGt_char,(val2),(long)4,(long)1,(4)*sizeof(char), ECPGd_indicator,
12274 ECPGt_int,&(val2i),(long)1,(long)1,sizeof(int), ECPGd_EODT);
12275
12276#line 26 "desc.pgc"
12277
12278if (sqlca.sqlcode < 0) sqlprint();}
12279#line 26 "desc.pgc"
12280
12281
12282 { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0);
12283=====================================================================
12284Found a 37 line (126 tokens) duplication in the following files:
12285Starting at line 1023 of /home/shackle/pggit/postgresql/src/backend/regex/regc_nfa.c
12286Starting at line 1109 of /home/shackle/pggit/postgresql/src/backend/regex/regc_nfa.c
12287
12288 }
12289 else
12290 {
12291 /*
12292 * With many arcs, use a sort-merge approach. Note that createarc()
12293 * will put new arcs onto the front of newState's chain, so it does
12294 * not break our walk through the sorted part of the chain.
12295 */
12296 struct arc *oa;
12297 struct arc *na;
12298
12299 /*
12300 * Because we bypass newarc() in this code path, we'd better include a
12301 * cancel check.
12302 */
12303 if (CANCEL_REQUESTED(nfa->v->re))
12304 {
12305 NERR(REG_CANCEL);
12306 return;
12307 }
12308
12309 sortouts(nfa, oldState);
12310 sortouts(nfa, newState);
12311 if (NISERR())
12312 return; /* might have failed to sort */
12313 oa = oldState->outs;
12314 na = newState->outs;
12315 while (oa != NULL && na != NULL)
12316 {
12317 struct arc *a = oa;
12318
12319 switch (sortouts_cmp(&oa, &na))
12320 {
12321 case -1:
12322 /* newState does not have anything matching oa */
12323 oa = oa->outchain;
12324 createarc(nfa, a->type, a->co, newState, a->to);
12325=====================================================================
12326Found a 4 line (126 tokens) duplication in the following files:
12327Starting at line 72 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
12328Starting at line 80 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
12329Starting at line 84 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
12330
12331 0, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
12332 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
12333 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
12334 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
12335=====================================================================
12336Found a 5 line (126 tokens) duplication in the following files:
12337Starting at line 98 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
12338Starting at line 103 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
12339
12340 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
12341 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
12342 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
12343 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
12344 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
12345=====================================================================
12346Found a 35 line (126 tokens) duplication in the following files:
12347Starting at line 509 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/funcapi.c
12348Starting at line 708 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/funcapi.c
12349
12350 if (!OidIsValid(anyelement_type) && !OidIsValid(anyarray_type) &&
12351 !OidIsValid(anyrange_type))
12352 return false;
12353
12354 /* If needed, deduce one polymorphic type from others */
12355 if (have_anyelement_result && !OidIsValid(anyelement_type))
12356 {
12357 if (OidIsValid(anyarray_type))
12358 anyelement_type = resolve_generic_type(ANYELEMENTOID,
12359 anyarray_type,
12360 ANYARRAYOID);
12361 if (OidIsValid(anyrange_type))
12362 {
12363 Oid subtype = resolve_generic_type(ANYELEMENTOID,
12364 anyrange_type,
12365 ANYRANGEOID);
12366
12367 /* check for inconsistent array and range results */
12368 if (OidIsValid(anyelement_type) && anyelement_type != subtype)
12369 return false;
12370 anyelement_type = subtype;
12371 }
12372 }
12373
12374 if (have_anyarray_result && !OidIsValid(anyarray_type))
12375 anyarray_type = resolve_generic_type(ANYARRAYOID,
12376 anyelement_type,
12377 ANYELEMENTOID);
12378
12379 /*
12380 * We can't deduce a range type from other polymorphic inputs, because
12381 * there may be multiple range types for the same subtype.
12382 */
12383 if (have_anyrange_result && !OidIsValid(anyrange_type))
12384 return false;
12385=====================================================================
12386Found a 34 line (126 tokens) duplication in the following files:
12387Starting at line 1165 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
12388Starting at line 2076 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
12389
12390 haveTextMonth, fmask,
12391 &tmask, tm,
12392 fsec, &is2digits);
12393 if (dterr)
12394 return dterr;
12395 }
12396 }
12397 break;
12398
12399 case DTK_STRING:
12400 case DTK_SPECIAL:
12401 /* timezone abbrevs take precedence over built-in tokens */
12402 type = DecodeTimezoneAbbrev(i, field[i], &val, &valtz);
12403 if (type == UNKNOWN_FIELD)
12404 type = DecodeSpecial(i, field[i], &val);
12405 if (type == IGNORE_DTF)
12406 continue;
12407
12408 tmask = DTK_M(type);
12409 switch (type)
12410 {
12411 case RESERV:
12412 switch (val)
12413 {
12414 case DTK_CURRENT:
12415 ereport(ERROR,
12416 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
12417 errmsg("date/time value \"current\" is no longer supported")));
12418
12419 return DTERR_BAD_FORMAT;
12420 break;
12421
12422 case DTK_NOW:
12423 tmask = (DTK_DATE_M | DTK_TIME_M | DTK_M(TZ));
12424=====================================================================
12425Found a 30 line (125 tokens) duplication in the following files:
12426Starting at line 376 of /home/shackle/pggit/postgresql/contrib/pageinspect/btreefuncs.c
12427Starting at line 461 of /home/shackle/pggit/postgresql/contrib/pageinspect/btreefuncs.c
12428
12429 opaque = (BTPageOpaque) PageGetSpecialPointer(uargs->page);
12430
12431 if (P_ISDELETED(opaque))
12432 elog(NOTICE, "page is deleted");
12433
12434 fctx->max_calls = PageGetMaxOffsetNumber(uargs->page);
12435
12436 /* Build a tuple descriptor for our result type */
12437 if (get_call_result_type(fcinfo, NULL, &tupleDesc) != TYPEFUNC_COMPOSITE)
12438 elog(ERROR, "return type must be a row type");
12439
12440 fctx->attinmeta = TupleDescGetAttInMetadata(tupleDesc);
12441
12442 fctx->user_fctx = uargs;
12443
12444 MemoryContextSwitchTo(mctx);
12445 }
12446
12447 fctx = SRF_PERCALL_SETUP();
12448 uargs = fctx->user_fctx;
12449
12450 if (fctx->call_cntr < fctx->max_calls)
12451 {
12452 result = bt_page_print_tuples(fctx, uargs->page, uargs->offset);
12453 uargs->offset++;
12454 SRF_RETURN_NEXT(fctx, result);
12455 }
12456 else
12457 {
12458 pfree(uargs->page);
12459=====================================================================
12460Found a 27 line (125 tokens) duplication in the following files:
12461Starting at line 425 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/interval.c
12462Starting at line 3182 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
12463
12464 case INTERVAL_MASK(MINUTE) | INTERVAL_MASK(SECOND):
12465 type = DTK_SECOND;
12466 break;
12467 default:
12468 type = DTK_SECOND;
12469 break;
12470 }
12471 }
12472
12473 errno = 0;
12474 val = strtoint(field[i], &cp, 10);
12475 if (errno == ERANGE)
12476 return DTERR_FIELD_OVERFLOW;
12477
12478 if (*cp == '-')
12479 {
12480 /* SQL "years-months" syntax */
12481 int val2;
12482
12483 val2 = strtoint(cp + 1, &cp, 10);
12484 if (errno == ERANGE || val2 < 0 || val2 >= MONTHS_PER_YEAR)
12485 return DTERR_FIELD_OVERFLOW;
12486 if (*cp != '\0')
12487 return DTERR_BAD_FORMAT;
12488 type = DTK_MONTH;
12489 if (*field[i] == '-')
12490 val2 = -val2;
12491=====================================================================
12492Found a 34 line (125 tokens) duplication in the following files:
12493Starting at line 1068 of /home/shackle/pggit/postgresql/src/backend/optimizer/plan/createplan.c
12494Starting at line 1218 of /home/shackle/pggit/postgresql/src/backend/optimizer/plan/createplan.c
12495
12496 subplans = lappend(subplans, subplan);
12497 }
12498
12499 /*
12500 * If any quals exist, they may be useful to perform further partition
12501 * pruning during execution. Gather information needed by the executor to
12502 * do partition pruning.
12503 */
12504 if (enable_partition_pruning &&
12505 rel->reloptkind == RELOPT_BASEREL &&
12506 best_path->partitioned_rels != NIL)
12507 {
12508 List *prunequal;
12509
12510 prunequal = extract_actual_clauses(rel->baserestrictinfo, false);
12511
12512 if (best_path->path.param_info)
12513 {
12514 List *prmquals = best_path->path.param_info->ppi_clauses;
12515
12516 prmquals = extract_actual_clauses(prmquals, false);
12517 prmquals = (List *) replace_nestloop_params(root,
12518 (Node *) prmquals);
12519
12520 prunequal = list_concat(prunequal, prmquals);
12521 }
12522
12523 if (prunequal != NIL)
12524 partpruneinfo =
12525 make_partition_pruneinfo(root, rel,
12526 best_path->subpaths,
12527 best_path->partitioned_rels,
12528 prunequal);
12529 }
12530=====================================================================
12531Found a 29 line (125 tokens) duplication in the following files:
12532Starting at line 907 of /home/shackle/pggit/postgresql/src/backend/utils/adt/arrayfuncs.c
12533Starting at line 1507 of /home/shackle/pggit/postgresql/src/backend/utils/adt/arrayfuncs.c
12534
12535 }
12536
12537 /*
12538 * Check for nulls, compute total data space needed
12539 */
12540 hasnull = false;
12541 totbytes = 0;
12542 for (i = 0; i < nitems; i++)
12543 {
12544 if (nulls[i])
12545 hasnull = true;
12546 else
12547 {
12548 /* let's just make sure data is not toasted */
12549 if (typlen == -1)
12550 values[i] = PointerGetDatum(PG_DETOAST_DATUM(values[i]));
12551 totbytes = att_addlength_datum(totbytes, typlen, values[i]);
12552 totbytes = att_align_nominal(totbytes, typalign);
12553 /* check for overflow of total request */
12554 if (!AllocSizeIsValid(totbytes))
12555 ereport(ERROR,
12556 (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
12557 errmsg("array size exceeds the maximum allowed (%d)",
12558 (int) MaxAllocSize)));
12559 }
12560 }
12561 *hasnulls = hasnull;
12562 *nbytes = totbytes;
12563}
12564=====================================================================
12565Found a 55 line (125 tokens) duplication in the following files:
12566Starting at line 971 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
12567Starting at line 1480 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
12568
12569 if (cmpresult < 0)
12570 {
12571 /* arg1 is less than arg2 */
12572 result = -1;
12573 break;
12574 }
12575 else if (cmpresult > 0)
12576 {
12577 /* arg1 is greater than arg2 */
12578 result = 1;
12579 break;
12580 }
12581 }
12582
12583 /* equal, so continue to next column */
12584 i1++, i2++, j++;
12585 }
12586
12587 /*
12588 * If we didn't break out of the loop early, check for column count
12589 * mismatch. (We do not report such mismatch if we found unequal column
12590 * values; is that a feature or a bug?)
12591 */
12592 if (result == 0)
12593 {
12594 if (i1 != ncolumns1 || i2 != ncolumns2)
12595 ereport(ERROR,
12596 (errcode(ERRCODE_DATATYPE_MISMATCH),
12597 errmsg("cannot compare record types with different numbers of columns")));
12598 }
12599
12600 pfree(values1);
12601 pfree(nulls1);
12602 pfree(values2);
12603 pfree(nulls2);
12604 ReleaseTupleDesc(tupdesc1);
12605 ReleaseTupleDesc(tupdesc2);
12606
12607 /* Avoid leaking memory when handed toasted input. */
12608 PG_FREE_IF_COPY(record1, 0);
12609 PG_FREE_IF_COPY(record2, 1);
12610
12611 return result;
12612}
12613
12614/*
12615 * record_eq :
12616 * compares two records for equality
12617 * result :
12618 * returns true if the records are equal, false otherwise.
12619 *
12620 * Note: we do not use record_cmp here, since equality may be meaningful in
12621 * datatypes that don't have a total ordering (and hence no btree support).
12622 */
12623Datum
12624=====================================================================
12625Found a 25 line (125 tokens) duplication in the following files:
12626Starting at line 308 of /home/shackle/pggit/postgresql/src/backend/access/nbtree/nbtpage.c
12627Starting at line 520 of /home/shackle/pggit/postgresql/src/backend/access/nbtree/nbtpage.c
12628Starting at line 608 of /home/shackle/pggit/postgresql/src/backend/access/nbtree/nbtpage.c
12629
12630 metabuf = _bt_getbuf(rel, BTREE_METAPAGE, BT_READ);
12631 metapg = BufferGetPage(metabuf);
12632 metaopaque = (BTPageOpaque) PageGetSpecialPointer(metapg);
12633 metad = BTPageGetMeta(metapg);
12634
12635 /* sanity-check the metapage */
12636 if (!P_ISMETA(metaopaque) ||
12637 metad->btm_magic != BTREE_MAGIC)
12638 ereport(ERROR,
12639 (errcode(ERRCODE_INDEX_CORRUPTED),
12640 errmsg("index \"%s\" is not a btree",
12641 RelationGetRelationName(rel))));
12642
12643 if (metad->btm_version < BTREE_MIN_VERSION ||
12644 metad->btm_version > BTREE_VERSION)
12645 ereport(ERROR,
12646 (errcode(ERRCODE_INDEX_CORRUPTED),
12647 errmsg("version mismatch in index \"%s\": file version %d, "
12648 "current version %d, minimal supported version %d",
12649 RelationGetRelationName(rel),
12650 metad->btm_version, BTREE_VERSION, BTREE_MIN_VERSION)));
12651
12652 /* if no root page initialized yet, do it */
12653 if (metad->btm_root == P_NONE)
12654 {
12655=====================================================================
12656Found a 42 line (125 tokens) duplication in the following files:
12657Starting at line 349 of /home/shackle/pggit/postgresql/src/backend/replication/logical/worker.c
12658Starting at line 423 of /home/shackle/pggit/postgresql/src/backend/replication/logical/worker.c
12659
12660 values[remoteattnum] != NULL)
12661 {
12662 Oid typinput;
12663 Oid typioparam;
12664
12665 errarg.local_attnum = i;
12666 errarg.remote_attnum = remoteattnum;
12667
12668 getTypeInputInfo(att->atttypid, &typinput, &typioparam);
12669 slot->tts_values[i] =
12670 OidInputFunctionCall(typinput, values[remoteattnum],
12671 typioparam, att->atttypmod);
12672 slot->tts_isnull[i] = false;
12673
12674 errarg.local_attnum = -1;
12675 errarg.remote_attnum = -1;
12676 }
12677 else
12678 {
12679 /*
12680 * We assign NULL to dropped attributes, NULL values, and missing
12681 * values (missing values should be later filled using
12682 * slot_fill_defaults).
12683 */
12684 slot->tts_values[i] = (Datum) 0;
12685 slot->tts_isnull[i] = true;
12686 }
12687 }
12688
12689 /* Pop the error context stack */
12690 error_context_stack = errcallback.previous;
12691
12692 ExecStoreVirtualTuple(slot);
12693}
12694
12695/*
12696 * Modify slot with user data provided as C strings.
12697 * This is somewhat similar to heap_modify_tuple but also calls the type
12698 * input function on the user data as the input is the text representation
12699 * of the types.
12700 */
12701static void
12702=====================================================================
12703Found a 33 line (124 tokens) duplication in the following files:
12704Starting at line 5504 of /home/shackle/pggit/postgresql/src/pl/plpgsql/src/pl_exec.c
12705Starting at line 5595 of /home/shackle/pggit/postgresql/src/pl/plpgsql/src/pl_exec.c
12706
12707 break;
12708 }
12709
12710 case PLPGSQL_DTYPE_RECFIELD:
12711 {
12712 PLpgSQL_recfield *recfield = (PLpgSQL_recfield *) datum;
12713 PLpgSQL_rec *rec;
12714
12715 rec = (PLpgSQL_rec *) (estate->datums[recfield->recparentno]);
12716
12717 /*
12718 * If record variable is NULL, instantiate it if it has a
12719 * named composite type, else complain. (This won't change
12720 * the logical state of the record: it's still NULL.)
12721 */
12722 if (rec->erh == NULL)
12723 instantiate_empty_record_variable(estate, rec);
12724
12725 /*
12726 * Look up the field's properties if we have not already, or
12727 * if the tuple descriptor ID changed since last time.
12728 */
12729 if (unlikely(recfield->rectupledescid != rec->erh->er_tupdesc_id))
12730 {
12731 if (!expanded_record_lookup_field(rec->erh,
12732 recfield->fieldname,
12733 &recfield->finfo))
12734 ereport(ERROR,
12735 (errcode(ERRCODE_UNDEFINED_COLUMN),
12736 errmsg("record \"%s\" has no field \"%s\"",
12737 rec->refname, recfield->fieldname)));
12738 recfield->rectupledescid = rec->erh->er_tupdesc_id;
12739 }
12740=====================================================================
12741Found a 28 line (124 tokens) duplication in the following files:
12742Starting at line 506 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/dt_common.c
12743Starting at line 3798 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
12744
12745datebsearch(const char *key, const datetkn *base, unsigned int nel)
12746{
12747 if (nel > 0)
12748 {
12749 const datetkn *last = base + nel - 1,
12750 *position;
12751 int result;
12752
12753 while (last >= base)
12754 {
12755 position = base + ((last - base) >> 1);
12756 /* precheck the first character for a bit of extra speed */
12757 result = (int) key[0] - (int) position->token[0];
12758 if (result == 0)
12759 {
12760 /* use strncmp so that we match truncated tokens */
12761 result = strncmp(key, position->token, TOKMAXLEN);
12762 if (result == 0)
12763 return position;
12764 }
12765 if (result < 0)
12766 last = position - 1;
12767 else
12768 base = position + 1;
12769 }
12770 }
12771 return NULL;
12772}
12773=====================================================================
12774Found a 31 line (124 tokens) duplication in the following files:
12775Starting at line 140 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-func.c
12776Starting at line 213 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-fetch.c
12777
12778 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table Log", ECPGt_EOIT, ECPGt_EORT);
12779#line 41 "func.pgc"
12780
12781if (sqlca.sqlwarn[0] == 'W') sqlprint();
12782#line 41 "func.pgc"
12783
12784if (sqlca.sqlcode < 0) sqlprint();}
12785#line 41 "func.pgc"
12786
12787 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table My_Table", ECPGt_EOIT, ECPGt_EORT);
12788#line 42 "func.pgc"
12789
12790if (sqlca.sqlwarn[0] == 'W') sqlprint();
12791#line 42 "func.pgc"
12792
12793if (sqlca.sqlcode < 0) sqlprint();}
12794#line 42 "func.pgc"
12795
12796
12797 { ECPGdisconnect(__LINE__, "ALL");
12798#line 44 "func.pgc"
12799
12800if (sqlca.sqlwarn[0] == 'W') sqlprint();
12801#line 44 "func.pgc"
12802
12803if (sqlca.sqlcode < 0) sqlprint();}
12804#line 44 "func.pgc"
12805
12806
12807 return 0;
12808}
12809=====================================================================
12810Found a 5 line (124 tokens) duplication in the following files:
12811Starting at line 98 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
12812Starting at line 103 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
12813
12814 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
12815 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
12816 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
12817 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
12818 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
12819=====================================================================
12820Found a 28 line (124 tokens) duplication in the following files:
12821Starting at line 1262 of /home/shackle/pggit/postgresql/src/backend/utils/adt/jsonb.c
12822Starting at line 2303 of /home/shackle/pggit/postgresql/src/backend/utils/adt/json.c
12823
12824 goto close_object;
12825 break;
12826
12827 case 1:
12828 if ((ARR_DIMS(in_array)[0]) % 2)
12829 ereport(ERROR,
12830 (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
12831 errmsg("array must have even number of elements")));
12832 break;
12833
12834 case 2:
12835 if ((ARR_DIMS(in_array)[1]) != 2)
12836 ereport(ERROR,
12837 (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
12838 errmsg("array must have two columns")));
12839 break;
12840
12841 default:
12842 ereport(ERROR,
12843 (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
12844 errmsg("wrong number of array subscripts")));
12845 }
12846
12847 deconstruct_array(in_array,
12848 TEXTOID, -1, false, 'i',
12849 &in_datums, &in_nulls, &in_count);
12850
12851 count = in_count / 2;
12852=====================================================================
12853Found a 34 line (124 tokens) duplication in the following files:
12854Starting at line 372 of /home/shackle/pggit/postgresql/src/backend/utils/adt/network_gist.c
12855Starting at line 434 of /home/shackle/pggit/postgresql/src/backend/utils/adt/network_gist.c
12856
12857 tmp = DatumGetInetKeyP(ent[i].key);
12858
12859 /* Determine range of family numbers */
12860 if (minfamily > gk_ip_family(tmp))
12861 minfamily = gk_ip_family(tmp);
12862 if (maxfamily < gk_ip_family(tmp))
12863 maxfamily = gk_ip_family(tmp);
12864
12865 /* Find minimum minbits */
12866 if (minbits > gk_ip_minbits(tmp))
12867 minbits = gk_ip_minbits(tmp);
12868
12869 /* Find minimum number of bits in common */
12870 if (commonbits > gk_ip_commonbits(tmp))
12871 commonbits = gk_ip_commonbits(tmp);
12872 if (commonbits > 0)
12873 commonbits = bitncommon(addr, gk_ip_addr(tmp), commonbits);
12874 }
12875
12876 /* Force minbits/commonbits to zero if more than one family. */
12877 if (minfamily != maxfamily)
12878 minbits = commonbits = 0;
12879
12880 *minfamily_p = minfamily;
12881 *maxfamily_p = maxfamily;
12882 *minbits_p = minbits;
12883 *commonbits_p = commonbits;
12884}
12885
12886/*
12887 * Same as above, but the GISTENTRY elements to examine are those with
12888 * indices listed in the offsets[] array.
12889 */
12890static void
12891=====================================================================
12892Found a 38 line (124 tokens) duplication in the following files:
12893Starting at line 496 of /home/shackle/pggit/postgresql/src/backend/access/heap/heapam.c
12894Starting at line 800 of /home/shackle/pggit/postgresql/src/backend/access/heap/heapam.c
12895
12896 int lines;
12897 OffsetNumber lineoff;
12898 int linesleft;
12899 ItemId lpp;
12900
12901 /*
12902 * calculate next starting lineoff, given scan direction
12903 */
12904 if (ScanDirectionIsForward(dir))
12905 {
12906 if (!scan->rs_inited)
12907 {
12908 /*
12909 * return null immediately if relation is empty
12910 */
12911 if (scan->rs_nblocks == 0 || scan->rs_numblocks == 0)
12912 {
12913 Assert(!BufferIsValid(scan->rs_cbuf));
12914 tuple->t_data = NULL;
12915 return;
12916 }
12917 if (scan->rs_parallel != NULL)
12918 {
12919 heap_parallelscan_startblock_init(scan);
12920
12921 page = heap_parallelscan_nextpage(scan);
12922
12923 /* Other processes might have already finished the scan. */
12924 if (page == InvalidBlockNumber)
12925 {
12926 Assert(!BufferIsValid(scan->rs_cbuf));
12927 tuple->t_data = NULL;
12928 return;
12929 }
12930 }
12931 else
12932 page = scan->rs_startblock; /* first page */
12933 heapgetpage(scan, page);
12934=====================================================================
12935Found a 34 line (123 tokens) duplication in the following files:
12936Starting at line 50 of /home/shackle/pggit/postgresql/contrib/hstore_plpython/hstore_plpython.c
12937Starting at line 34 of /home/shackle/pggit/postgresql/contrib/hstore_plperl/hstore_plperl.c
12938
12939 AssertVariableIsOfType(&hstoreUpgrade, hstoreUpgrade_t);
12940 hstoreUpgrade_p = (hstoreUpgrade_t)
12941 load_external_function("$libdir/hstore", "hstoreUpgrade",
12942 true, NULL);
12943 AssertVariableIsOfType(&hstoreUniquePairs, hstoreUniquePairs_t);
12944 hstoreUniquePairs_p = (hstoreUniquePairs_t)
12945 load_external_function("$libdir/hstore", "hstoreUniquePairs",
12946 true, NULL);
12947 AssertVariableIsOfType(&hstorePairs, hstorePairs_t);
12948 hstorePairs_p = (hstorePairs_t)
12949 load_external_function("$libdir/hstore", "hstorePairs",
12950 true, NULL);
12951 AssertVariableIsOfType(&hstoreCheckKeyLen, hstoreCheckKeyLen_t);
12952 hstoreCheckKeyLen_p = (hstoreCheckKeyLen_t)
12953 load_external_function("$libdir/hstore", "hstoreCheckKeyLen",
12954 true, NULL);
12955 AssertVariableIsOfType(&hstoreCheckValLen, hstoreCheckValLen_t);
12956 hstoreCheckValLen_p = (hstoreCheckValLen_t)
12957 load_external_function("$libdir/hstore", "hstoreCheckValLen",
12958 true, NULL);
12959}
12960
12961
12962/* These defines must be after the module init function */
12963#define PLyObject_AsString PLyObject_AsString_p
12964#define PLyUnicode_FromStringAndSize PLyUnicode_FromStringAndSize_p
12965#define hstoreUpgrade hstoreUpgrade_p
12966#define hstoreUniquePairs hstoreUniquePairs_p
12967#define hstorePairs hstorePairs_p
12968#define hstoreCheckKeyLen hstoreCheckKeyLen_p
12969#define hstoreCheckValLen hstoreCheckValLen_p
12970
12971
12972PG_FUNCTION_INFO_V1(hstore_to_plpython);
12973=====================================================================
12974Found a 20 line (123 tokens) duplication in the following files:
12975Starting at line 62 of /home/shackle/pggit/postgresql/contrib/bloom/blvalidate.c
12976Starting at line 63 of /home/shackle/pggit/postgresql/src/backend/access/gin/ginvalidate.c
12977Starting at line 63 of /home/shackle/pggit/postgresql/src/backend/access/gist/gistvalidate.c
12978Starting at line 70 of /home/shackle/pggit/postgresql/src/backend/access/hash/hashvalidate.c
12979
12980 opckeytype = opcintype;
12981 opclassname = NameStr(classform->opcname);
12982
12983 /* Fetch opfamily information */
12984 familytup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfamilyoid));
12985 if (!HeapTupleIsValid(familytup))
12986 elog(ERROR, "cache lookup failed for operator family %u", opfamilyoid);
12987 familyform = (Form_pg_opfamily) GETSTRUCT(familytup);
12988
12989 opfamilyname = NameStr(familyform->opfname);
12990
12991 /* Fetch all operators and support functions of the opfamily */
12992 oprlist = SearchSysCacheList1(AMOPSTRATEGY, ObjectIdGetDatum(opfamilyoid));
12993 proclist = SearchSysCacheList1(AMPROCNUM, ObjectIdGetDatum(opfamilyoid));
12994
12995 /* Check individual support functions */
12996 for (i = 0; i < proclist->n_members; i++)
12997 {
12998 HeapTuple proctup = &proclist->members[i]->tuple;
12999 Form_pg_amproc procform = (Form_pg_amproc) GETSTRUCT(proctup);
13000=====================================================================
13001Found a 3 line (123 tokens) duplication in the following files:
13002Starting at line 31 of /home/shackle/pggit/postgresql/src/common/base64.c
13003Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
13004Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
13005Starting at line 207 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
13006Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
13007
13008 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
13009 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
13010 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
13011=====================================================================
13012Found a 3 line (123 tokens) duplication in the following files:
13013Starting at line 31 of /home/shackle/pggit/postgresql/src/common/base64.c
13014Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
13015Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
13016Starting at line 207 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
13017Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
13018
13019 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
13020 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
13021 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
13022=====================================================================
13023Found a 35 line (123 tokens) duplication in the following files:
13024Starting at line 507 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-sqlda.c
13025Starting at line 446 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-describe.c
13026
13027 { ECPGdisconnect(__LINE__, "con2");
13028#line 248 "sqlda.pgc"
13029
13030if (sqlca.sqlcode < 0) exit (1);}
13031#line 248 "sqlda.pgc"
13032
13033
13034 /* End test */
13035
13036 strcpy(msg, "drop");
13037 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT);
13038#line 253 "sqlda.pgc"
13039
13040if (sqlca.sqlcode < 0) exit (1);}
13041#line 253 "sqlda.pgc"
13042
13043
13044 strcpy(msg, "commit");
13045 { ECPGtrans(__LINE__, NULL, "commit");
13046#line 256 "sqlda.pgc"
13047
13048if (sqlca.sqlcode < 0) exit (1);}
13049#line 256 "sqlda.pgc"
13050
13051
13052 strcpy(msg, "disconnect");
13053 { ECPGdisconnect(__LINE__, "CURRENT");
13054#line 259 "sqlda.pgc"
13055
13056if (sqlca.sqlcode < 0) exit (1);}
13057#line 259 "sqlda.pgc"
13058
13059
13060 return 0;
13061}
13062=====================================================================
13063Found a 27 line (123 tokens) duplication in the following files:
13064Starting at line 76 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-describe.c
13065Starting at line 59 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-describe.c
13066
13067 char field_name2 [ 30 ] = "not set" ;
13068/* exec sql end declare section */
13069#line 20 "describe.pgc"
13070
13071
13072 char msg[128];
13073
13074 ECPGdebug(1, stderr);
13075
13076 strcpy(msg, "connect");
13077 { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0);
13078#line 27 "describe.pgc"
13079
13080if (sqlca.sqlcode < 0) exit (1);}
13081#line 27 "describe.pgc"
13082
13083
13084 strcpy(msg, "set");
13085 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
13086#line 30 "describe.pgc"
13087
13088if (sqlca.sqlcode < 0) exit (1);}
13089#line 30 "describe.pgc"
13090
13091
13092 strcpy(msg, "create");
13093 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table descr_t2 ( id serial primary key , t text )", ECPGt_EOIT, ECPGt_EORT);
13094=====================================================================
13095Found a 10 line (123 tokens) duplication in the following files:
13096Starting at line 326 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
13097Starting at line 340 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
13098Starting at line 355 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
13099Starting at line 370 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
13100Starting at line 388 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
13101Starting at line 403 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
13102Starting at line 417 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
13103Starting at line 435 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
13104
13105 { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "declare $0 cursor for select id , t from t1",
13106 ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
13107 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
13108 ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
13109 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
13110 ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
13111 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
13112#line 108 "cursor.pgc"
13113
13114if (sqlca.sqlcode < 0) exit (1);}
13115=====================================================================
13116Found a 21 line (123 tokens) duplication in the following files:
13117Starting at line 2064 of /home/shackle/pggit/postgresql/src/backend/nodes/nodeFuncs.c
13118Starting at line 3328 of /home/shackle/pggit/postgresql/src/backend/nodes/nodeFuncs.c
13119
13120 break;
13121 case T_CoalesceExpr:
13122 return walker(((CoalesceExpr *) node)->args, context);
13123 case T_MinMaxExpr:
13124 return walker(((MinMaxExpr *) node)->args, context);
13125 case T_XmlExpr:
13126 {
13127 XmlExpr *xexpr = (XmlExpr *) node;
13128
13129 if (walker(xexpr->named_args, context))
13130 return true;
13131 /* we assume walker doesn't care about arg_names */
13132 if (walker(xexpr->args, context))
13133 return true;
13134 }
13135 break;
13136 case T_NullTest:
13137 return walker(((NullTest *) node)->arg, context);
13138 case T_BooleanTest:
13139 return walker(((BooleanTest *) node)->arg, context);
13140 case T_CoerceToDomain:
13141=====================================================================
13142Found a 29 line (123 tokens) duplication in the following files:
13143Starting at line 3275 of /home/shackle/pggit/postgresql/src/backend/utils/adt/jsonfuncs.c
13144Starting at line 3630 of /home/shackle/pggit/postgresql/src/backend/utils/adt/jsonfuncs.c
13145
13146 old_cxt = MemoryContextSwitchTo(fnmcxt);
13147 cache->c.io.composite.tupdesc = CreateTupleDescCopy(tupdesc);
13148 cache->c.io.composite.base_typid = tupdesc->tdtypeid;
13149 cache->c.io.composite.base_typmod = tupdesc->tdtypmod;
13150 MemoryContextSwitchTo(old_cxt);
13151 }
13152 }
13153
13154 /* Collect record arg if we have one */
13155 if (have_record_arg && !PG_ARGISNULL(0))
13156 {
13157 rec = PG_GETARG_HEAPTUPLEHEADER(0);
13158
13159 /*
13160 * When declared arg type is RECORD, identify actual record type from
13161 * the tuple itself. Note the lookup_rowtype_tupdesc call in
13162 * update_cached_tupdesc will fail if we're unable to do this.
13163 */
13164 if (cache->argtype == RECORDOID)
13165 {
13166 cache->c.io.composite.base_typid = HeapTupleHeaderGetTypeId(rec);
13167 cache->c.io.composite.base_typmod = HeapTupleHeaderGetTypMod(rec);
13168 }
13169 }
13170 else
13171 rec = NULL;
13172
13173 /* If no JSON argument, just return the record (if any) unchanged */
13174 if (PG_ARGISNULL(json_arg_num))
13175=====================================================================
13176Found a 25 line (123 tokens) duplication in the following files:
13177Starting at line 173 of /home/shackle/pggit/postgresql/src/backend/utils/adt/inet_net_pton.c
13178Starting at line 293 of /home/shackle/pggit/postgresql/src/backend/utils/adt/inet_net_pton.c
13179
13180 bits = -1;
13181 if (ch == '/' && isdigit((unsigned char) src[0]) && dst > odst)
13182 {
13183 /* CIDR width specifier. Nothing can follow it. */
13184 ch = *src++; /* Skip over the /. */
13185 bits = 0;
13186 do
13187 {
13188 n = strchr(digits, ch) - digits;
13189 assert(n >= 0 && n <= 9);
13190 bits *= 10;
13191 bits += n;
13192 } while ((ch = *src++) != '\0' && isdigit((unsigned char) ch));
13193 if (ch != '\0')
13194 goto enoent;
13195 if (bits > 32)
13196 goto emsgsize;
13197 }
13198
13199 /* Firey death and destruction unless we prefetched EOS. */
13200 if (ch != '\0')
13201 goto enoent;
13202
13203 /* If nothing was written to the destination, we found no address. */
13204 if (dst == odst)
13205=====================================================================
13206Found a 42 line (123 tokens) duplication in the following files:
13207Starting at line 2257 of /home/shackle/pggit/postgresql/src/backend/commands/event_trigger.c
13208Starting at line 2339 of /home/shackle/pggit/postgresql/src/backend/commands/event_trigger.c
13209
13210 return "TYPE";
13211 /* these currently aren't used */
13212 case OBJECT_ACCESS_METHOD:
13213 case OBJECT_AGGREGATE:
13214 case OBJECT_AMOP:
13215 case OBJECT_AMPROC:
13216 case OBJECT_ATTRIBUTE:
13217 case OBJECT_CAST:
13218 case OBJECT_COLLATION:
13219 case OBJECT_CONVERSION:
13220 case OBJECT_DEFAULT:
13221 case OBJECT_DEFACL:
13222 case OBJECT_DOMCONSTRAINT:
13223 case OBJECT_EVENT_TRIGGER:
13224 case OBJECT_EXTENSION:
13225 case OBJECT_FOREIGN_TABLE:
13226 case OBJECT_INDEX:
13227 case OBJECT_MATVIEW:
13228 case OBJECT_OPCLASS:
13229 case OBJECT_OPERATOR:
13230 case OBJECT_OPFAMILY:
13231 case OBJECT_POLICY:
13232 case OBJECT_PUBLICATION:
13233 case OBJECT_PUBLICATION_REL:
13234 case OBJECT_ROLE:
13235 case OBJECT_RULE:
13236 case OBJECT_STATISTIC_EXT:
13237 case OBJECT_SUBSCRIPTION:
13238 case OBJECT_TABCONSTRAINT:
13239 case OBJECT_TRANSFORM:
13240 case OBJECT_TRIGGER:
13241 case OBJECT_TSCONFIGURATION:
13242 case OBJECT_TSDICTIONARY:
13243 case OBJECT_TSPARSER:
13244 case OBJECT_TSTEMPLATE:
13245 case OBJECT_USER_MAPPING:
13246 case OBJECT_VIEW:
13247 elog(ERROR, "unsupported object type: %d", (int) objtype);
13248 }
13249
13250 return "???"; /* keep compiler quiet */
13251}
13252=====================================================================
13253Found a 33 line (123 tokens) duplication in the following files:
13254Starting at line 94 of /home/shackle/pggit/postgresql/src/backend/access/rmgrdesc/xactdesc.c
13255Starting at line 178 of /home/shackle/pggit/postgresql/src/backend/access/rmgrdesc/xactdesc.c
13256
13257 data += xl_invals->nmsgs * sizeof(SharedInvalidationMessage);
13258 }
13259
13260 if (parsed->xinfo & XACT_XINFO_HAS_TWOPHASE)
13261 {
13262 xl_xact_twophase *xl_twophase = (xl_xact_twophase *) data;
13263
13264 parsed->twophase_xid = xl_twophase->xid;
13265
13266 data += sizeof(xl_xact_twophase);
13267
13268 if (parsed->xinfo & XACT_XINFO_HAS_GID)
13269 {
13270 strlcpy(parsed->twophase_gid, data, sizeof(parsed->twophase_gid));
13271 data += strlen(data) + 1;
13272 }
13273 }
13274
13275 /* Note: no alignment is guaranteed after this point */
13276
13277 if (parsed->xinfo & XACT_XINFO_HAS_ORIGIN)
13278 {
13279 xl_xact_origin xl_origin;
13280
13281 /* no alignment is guaranteed, so copy onto stack */
13282 memcpy(&xl_origin, data, sizeof(xl_origin));
13283
13284 parsed->origin_lsn = xl_origin.origin_lsn;
13285 parsed->origin_timestamp = xl_origin.origin_timestamp;
13286
13287 data += sizeof(xl_xact_origin);
13288 }
13289}
13290=====================================================================
13291Found a 33 line (123 tokens) duplication in the following files:
13292Starting at line 87 of /home/shackle/pggit/postgresql/src/backend/access/tablesample/bernoulli.c
13293Starting at line 90 of /home/shackle/pggit/postgresql/src/backend/access/tablesample/system.c
13294
13295bernoulli_samplescangetsamplesize(PlannerInfo *root,
13296 RelOptInfo *baserel,
13297 List *paramexprs,
13298 BlockNumber *pages,
13299 double *tuples)
13300{
13301 Node *pctnode;
13302 float4 samplefract;
13303
13304 /* Try to extract an estimate for the sample percentage */
13305 pctnode = (Node *) linitial(paramexprs);
13306 pctnode = estimate_expression_value(root, pctnode);
13307
13308 if (IsA(pctnode, Const) &&
13309 !((Const *) pctnode)->constisnull)
13310 {
13311 samplefract = DatumGetFloat4(((Const *) pctnode)->constvalue);
13312 if (samplefract >= 0 && samplefract <= 100 && !isnan(samplefract))
13313 samplefract /= 100.0f;
13314 else
13315 {
13316 /* Default samplefract if the value is bogus */
13317 samplefract = 0.1f;
13318 }
13319 }
13320 else
13321 {
13322 /* Default samplefract if we didn't obtain a non-null Const */
13323 samplefract = 0.1f;
13324 }
13325
13326 /* We'll visit all pages of the baserel */
13327 *pages = baserel->pages;
13328=====================================================================
13329Found a 27 line (122 tokens) duplication in the following files:
13330Starting at line 665 of /home/shackle/pggit/postgresql/contrib/hstore/hstore_io.c
13331Starting at line 1263 of /home/shackle/pggit/postgresql/src/backend/utils/adt/jsonb.c
13332Starting at line 2304 of /home/shackle/pggit/postgresql/src/backend/utils/adt/json.c
13333
13334 PG_RETURN_POINTER(out);
13335
13336 case 1:
13337 if ((ARR_DIMS(in_array)[0]) % 2)
13338 ereport(ERROR,
13339 (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
13340 errmsg("array must have even number of elements")));
13341 break;
13342
13343 case 2:
13344 if ((ARR_DIMS(in_array)[1]) != 2)
13345 ereport(ERROR,
13346 (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
13347 errmsg("array must have two columns")));
13348 break;
13349
13350 default:
13351 ereport(ERROR,
13352 (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
13353 errmsg("wrong number of array subscripts")));
13354 }
13355
13356 deconstruct_array(in_array,
13357 TEXTOID, -1, false, 'i',
13358 &in_datums, &in_nulls, &in_count);
13359
13360 count = in_count / 2;
13361=====================================================================
13362Found a 35 line (122 tokens) duplication in the following files:
13363Starting at line 304 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/compat_informix-describe.c
13364Starting at line 302 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-describe.c
13365
13366 { ECPGdeallocate(__LINE__, 1, NULL, "st_id1");
13367#line 132 "describe.pgc"
13368
13369if (sqlca.sqlcode < 0) exit (1);}
13370#line 132 "describe.pgc"
13371
13372
13373 /* Test DESCRIBE with a query not producing tuples */
13374
13375 strcpy(msg, "allocate");
13376 ECPGallocate_desc(__LINE__, "desc1");
13377#line 137 "describe.pgc"
13378
13379if (sqlca.sqlcode < 0) exit (1);
13380#line 137 "describe.pgc"
13381
13382 ECPGallocate_desc(__LINE__, "desc2");
13383#line 138 "describe.pgc"
13384
13385if (sqlca.sqlcode < 0) exit (1);
13386#line 138 "describe.pgc"
13387
13388
13389 strcpy(msg, "prepare");
13390 { ECPGprepare(__LINE__, NULL, 0, "st_id2", stmt2);
13391#line 141 "describe.pgc"
13392
13393if (sqlca.sqlcode < 0) exit (1);}
13394#line 141 "describe.pgc"
13395
13396
13397 sqlda1 = sqlda2 = sqlda3 = NULL;
13398
13399 strcpy(msg, "describe");
13400 { ECPGdescribe(__LINE__, 1, 0, NULL, "st_id2",
13401=====================================================================
13402Found a 31 line (122 tokens) duplication in the following files:
13403Starting at line 2873 of /home/shackle/pggit/postgresql/src/backend/executor/execExprInterp.c
13404Starting at line 2920 of /home/shackle/pggit/postgresql/src/backend/executor/execExprInterp.c
13405
13406 tupDesc = expanded_record_get_tupdesc(erh);
13407
13408 /*
13409 * Find field's attr record. Note we don't support system columns
13410 * here: a datum tuple doesn't have valid values for most of the
13411 * interesting system columns anyway.
13412 */
13413 if (fieldnum <= 0) /* should never happen */
13414 elog(ERROR, "unsupported reference to system column %d in FieldSelect",
13415 fieldnum);
13416 if (fieldnum > tupDesc->natts) /* should never happen */
13417 elog(ERROR, "attribute number %d exceeds number of columns %d",
13418 fieldnum, tupDesc->natts);
13419 attr = TupleDescAttr(tupDesc, fieldnum - 1);
13420
13421 /* Check for dropped column, and force a NULL result if so */
13422 if (attr->attisdropped)
13423 {
13424 *op->resnull = true;
13425 return;
13426 }
13427
13428 /* Check for type mismatch --- possible after ALTER COLUMN TYPE? */
13429 /* As in CheckVarSlotCompatibility, we should but can't check typmod */
13430 if (op->d.fieldselect.resulttype != attr->atttypid)
13431 ereport(ERROR,
13432 (errcode(ERRCODE_DATATYPE_MISMATCH),
13433 errmsg("attribute %d has wrong type", fieldnum),
13434 errdetail("Table has type %s, but query expects %s.",
13435 format_type_be(attr->atttypid),
13436 format_type_be(op->d.fieldselect.resulttype))));
13437=====================================================================
13438Found a 30 line (122 tokens) duplication in the following files:
13439Starting at line 1852 of /home/shackle/pggit/postgresql/src/backend/executor/execMain.c
13440Starting at line 1982 of /home/shackle/pggit/postgresql/src/backend/executor/execMain.c
13441Starting at line 2090 of /home/shackle/pggit/postgresql/src/backend/executor/execMain.c
13442
13443 if (resultRelInfo->ri_PartitionRoot)
13444 {
13445 TupleDesc old_tupdesc = RelationGetDescr(rel);
13446 AttrNumber *map;
13447
13448 rel = resultRelInfo->ri_PartitionRoot;
13449 tupdesc = RelationGetDescr(rel);
13450 /* a reverse map */
13451 map = convert_tuples_by_name_map_if_req(old_tupdesc, tupdesc,
13452 gettext_noop("could not convert row type"));
13453
13454 /*
13455 * Partition-specific slot's tupdesc can't be changed, so allocate a
13456 * new one.
13457 */
13458 if (map != NULL)
13459 slot = execute_attr_map_slot(map, slot,
13460 MakeTupleTableSlot(tupdesc, &TTSOpsVirtual));
13461 }
13462
13463 insertedCols = GetInsertedColumns(resultRelInfo, estate);
13464 updatedCols = GetUpdatedColumns(resultRelInfo, estate);
13465 modifiedCols = bms_union(insertedCols, updatedCols);
13466 val_desc = ExecBuildSlotValueDescription(RelationGetRelid(rel),
13467 slot,
13468 tupdesc,
13469 modifiedCols,
13470 64);
13471 ereport(ERROR,
13472 (errcode(ERRCODE_CHECK_VIOLATION),
13473=====================================================================
13474Found a 5 line (122 tokens) duplication in the following files:
13475Starting at line 98 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
13476Starting at line 103 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
13477
13478 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
13479 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
13480 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
13481 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
13482 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
13483=====================================================================
13484Found a 18 line (122 tokens) duplication in the following files:
13485Starting at line 1002 of /home/shackle/pggit/postgresql/src/backend/utils/adt/tsvector_op.c
13486Starting at line 1083 of /home/shackle/pggit/postgresql/src/backend/utils/adt/tsvector_op.c
13487
13488 if (cmp < 0)
13489 { /* in1 first */
13490 ptr->haspos = ptr1->haspos;
13491 ptr->len = ptr1->len;
13492 memcpy(data + dataoff, data1 + ptr1->pos, ptr1->len);
13493 ptr->pos = dataoff;
13494 dataoff += ptr1->len;
13495 if (ptr->haspos)
13496 {
13497 dataoff = SHORTALIGN(dataoff);
13498 memcpy(data + dataoff, _POSVECPTR(in1, ptr1), POSDATALEN(in1, ptr1) * sizeof(WordEntryPos) + sizeof(uint16));
13499 dataoff += POSDATALEN(in1, ptr1) * sizeof(WordEntryPos) + sizeof(uint16);
13500 }
13501
13502 ptr++;
13503 ptr1++;
13504 i1--;
13505 }
13506=====================================================================
13507Found a 47 line (122 tokens) duplication in the following files:
13508Starting at line 2124 of /home/shackle/pggit/postgresql/src/backend/commands/analyze.c
13509Starting at line 2489 of /home/shackle/pggit/postgresql/src/backend/commands/analyze.c
13510
13511 int f1 = nonnull_cnt - summultiple;
13512 int d = f1 + nmultiple;
13513 double n = samplerows - null_cnt;
13514 double N = totalrows * (1.0 - stats->stanullfrac);
13515 double stadistinct;
13516
13517 /* N == 0 shouldn't happen, but just in case ... */
13518 if (N > 0)
13519 stadistinct = (n * d) / ((n - f1) + f1 * n / N);
13520 else
13521 stadistinct = 0;
13522
13523 /* Clamp to sane range in case of roundoff error */
13524 if (stadistinct < d)
13525 stadistinct = d;
13526 if (stadistinct > N)
13527 stadistinct = N;
13528 /* And round to integer */
13529 stats->stadistinct = floor(stadistinct + 0.5);
13530 }
13531
13532 /*
13533 * If we estimated the number of distinct values at more than 10% of
13534 * the total row count (a very arbitrary limit), then assume that
13535 * stadistinct should scale with the row count rather than be a fixed
13536 * value.
13537 */
13538 if (stats->stadistinct > 0.1 * totalrows)
13539 stats->stadistinct = -(stats->stadistinct / totalrows);
13540
13541 /*
13542 * Decide how many values are worth storing as most-common values. If
13543 * we are able to generate a complete MCV list (all the values in the
13544 * sample will fit, and we think these are all the ones in the table),
13545 * then do so. Otherwise, store only those values that are
13546 * significantly more common than the values not in the list.
13547 *
13548 * Note: the first of these cases is meant to address columns with
13549 * small, fixed sets of possible values, such as boolean or enum
13550 * columns. If we can *completely* represent the column population by
13551 * an MCV list that will fit into the stats target, then we should do
13552 * so and thus provide the planner with complete information. But if
13553 * the MCV list is not complete, it's generally worth being more
13554 * selective, and not just filling it all the way up to the stats
13555 * target.
13556 */
13557 if (track_cnt < track_max && toowide_cnt == 0 &&
13558=====================================================================
13559Found a 10 line (121 tokens) duplication in the following files:
13560Starting at line 44 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_backup_tar.c
13561Starting at line 38 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_backup_custom.c
13562
13563static void _ArchiveEntry(ArchiveHandle *AH, TocEntry *te);
13564static void _StartData(ArchiveHandle *AH, TocEntry *te);
13565static void _WriteData(ArchiveHandle *AH, const void *data, size_t dLen);
13566static void _EndData(ArchiveHandle *AH, TocEntry *te);
13567static int _WriteByte(ArchiveHandle *AH, const int i);
13568static int _ReadByte(ArchiveHandle *);
13569static void _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len);
13570static void _ReadBuf(ArchiveHandle *AH, void *buf, size_t len);
13571static void _CloseArchive(ArchiveHandle *AH);
13572static void _PrintTocData(ArchiveHandle *AH, TocEntry *te);
13573=====================================================================
13574Found a 36 line (121 tokens) duplication in the following files:
13575Starting at line 917 of /home/shackle/pggit/postgresql/src/bin/pg_dump/dumputils.c
13576Starting at line 3546 of /home/shackle/pggit/postgresql/src/backend/utils/adt/varlena.c
13577
13578 while (isspace((unsigned char) *nextp))
13579 nextp++; /* skip leading whitespace */
13580
13581 if (*nextp == '\0')
13582 return true; /* allow empty string */
13583
13584 /* At the top of the loop, we are at start of a new identifier. */
13585 do
13586 {
13587 char *curname;
13588 char *endp;
13589
13590 if (*nextp == '"')
13591 {
13592 /* Quoted name --- collapse quote-quote pairs */
13593 curname = nextp + 1;
13594 for (;;)
13595 {
13596 endp = strchr(nextp + 1, '"');
13597 if (endp == NULL)
13598 return false; /* mismatched quotes */
13599 if (endp[1] != '"')
13600 break; /* found end of quoted name */
13601 /* Collapse adjacent quotes into one quote, and look again */
13602 memmove(endp, endp + 1, strlen(endp));
13603 nextp = endp;
13604 }
13605 /* endp now points at the terminating quote */
13606 nextp = endp + 1;
13607 }
13608 else
13609 {
13610 /* Unquoted name --- extends to separator or whitespace */
13611 curname = nextp;
13612 while (*nextp && *nextp != separator &&
13613 !isspace((unsigned char) *nextp))
13614=====================================================================
13615Found a 21 line (121 tokens) duplication in the following files:
13616Starting at line 93 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-show.c
13617Starting at line 108 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-quote.c
13618
13619 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set standard_conforming_strings to off", ECPGt_EOIT, ECPGt_EORT);
13620#line 26 "show.pgc"
13621
13622if (sqlca.sqlwarn[0] == 'W') sqlprint();
13623#line 26 "show.pgc"
13624
13625if (sqlca.sqlcode < 0) sqlprint();}
13626#line 26 "show.pgc"
13627
13628 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "show standard_conforming_strings", ECPGt_EOIT,
13629 ECPGt_char,(var),(long)25,(long)1,(25)*sizeof(char),
13630 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
13631#line 27 "show.pgc"
13632
13633if (sqlca.sqlwarn[0] == 'W') sqlprint();
13634#line 27 "show.pgc"
13635
13636if (sqlca.sqlcode < 0) sqlprint();}
13637#line 27 "show.pgc"
13638
13639 printf("Var: Standard conforming strings: %s\n", var);
13640=====================================================================
13641Found a 25 line (121 tokens) duplication in the following files:
13642Starting at line 1247 of /home/shackle/pggit/postgresql/src/backend/executor/nodeIndexscan.c
13643Starting at line 1494 of /home/shackle/pggit/postgresql/src/backend/executor/nodeIndexscan.c
13644
13645 leftop = (Expr *) get_leftop(clause);
13646
13647 if (leftop && IsA(leftop, RelabelType))
13648 leftop = ((RelabelType *) leftop)->arg;
13649
13650 Assert(leftop != NULL);
13651
13652 if (!(IsA(leftop, Var) &&
13653 ((Var *) leftop)->varno == INDEX_VAR))
13654 elog(ERROR, "indexqual doesn't have key on left side");
13655
13656 varattno = ((Var *) leftop)->varattno;
13657 if (varattno < 1 || varattno > indnkeyatts)
13658 elog(ERROR, "bogus index qualification");
13659
13660 /*
13661 * We have to look up the operator's strategy number. This
13662 * provides a cross-check that the operator does match the index.
13663 */
13664 opfamily = index->rd_opfamily[varattno - 1];
13665
13666 get_op_opfamily_properties(opno, opfamily, isorderby,
13667 &op_strategy,
13668 &op_lefttype,
13669 &op_righttype);
13670=====================================================================
13671Found a 18 line (121 tokens) duplication in the following files:
13672Starting at line 1213 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
13673Starting at line 1520 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
13674
13675 InitFunctionCallInfoData(fcinfo, flinfo, 5, collation, NULL, NULL);
13676
13677 fcinfo.arg[0] = arg1;
13678 fcinfo.arg[1] = arg2;
13679 fcinfo.arg[2] = arg3;
13680 fcinfo.arg[3] = arg4;
13681 fcinfo.arg[4] = arg5;
13682 fcinfo.argnull[0] = false;
13683 fcinfo.argnull[1] = false;
13684 fcinfo.argnull[2] = false;
13685 fcinfo.argnull[3] = false;
13686 fcinfo.argnull[4] = false;
13687
13688 result = FunctionCallInvoke(&fcinfo);
13689
13690 /* Check for null result, since caller is clearly not expecting one */
13691 if (fcinfo.isnull)
13692 elog(ERROR, "function %u returned NULL", fcinfo.flinfo->fn_oid);
13693=====================================================================
13694Found a 28 line (121 tokens) duplication in the following files:
13695Starting at line 496 of /home/shackle/pggit/postgresql/src/backend/commands/opclasscmds.c
13696Starting at line 875 of /home/shackle/pggit/postgresql/src/backend/commands/opclasscmds.c
13697
13698 false, -1);
13699 }
13700
13701 if (item->order_family)
13702 sortfamilyOid = get_opfamily_oid(BTREE_AM_OID,
13703 item->order_family,
13704 false);
13705 else
13706 sortfamilyOid = InvalidOid;
13707
13708#ifdef NOT_USED
13709 /* XXX this is unnecessary given the superuser check above */
13710 /* Caller must own operator and its underlying function */
13711 if (!pg_oper_ownercheck(operOid, GetUserId()))
13712 aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_OPERATOR,
13713 get_opname(operOid));
13714 funcOid = get_opcode(operOid);
13715 if (!pg_proc_ownercheck(funcOid, GetUserId()))
13716 aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_FUNCTION,
13717 get_func_name(funcOid));
13718#endif
13719
13720 /* Save the info */
13721 member = (OpFamilyMember *) palloc0(sizeof(OpFamilyMember));
13722 member->object = operOid;
13723 member->number = item->number;
13724 member->sortfamily = sortfamilyOid;
13725 assignOperTypes(member, amoid, typeoid);
13726=====================================================================
13727Found a 27 line (121 tokens) duplication in the following files:
13728Starting at line 2350 of /home/shackle/pggit/postgresql/src/backend/commands/typecmds.c
13729Starting at line 2764 of /home/shackle/pggit/postgresql/src/backend/commands/typecmds.c
13730
13731 ListCell *rt;
13732
13733 /* Fetch relation list with attributes based on this domain */
13734 /* ShareLock is sufficient to prevent concurrent data changes */
13735
13736 rels = get_rels_with_domain(domainoid, ShareLock);
13737
13738 foreach(rt, rels)
13739 {
13740 RelToCheck *rtc = (RelToCheck *) lfirst(rt);
13741 Relation testrel = rtc->rel;
13742 TupleDesc tupdesc = RelationGetDescr(testrel);
13743 HeapScanDesc scan;
13744 HeapTuple tuple;
13745 Snapshot snapshot;
13746
13747 /* Scan all tuples in this relation */
13748 snapshot = RegisterSnapshot(GetLatestSnapshot());
13749 scan = heap_beginscan(testrel, snapshot, 0, NULL);
13750 while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
13751 {
13752 int i;
13753
13754 /* Test attributes that are of the domain */
13755 for (i = 0; i < rtc->natts; i++)
13756 {
13757 int attnum = rtc->atts[i];
13758=====================================================================
13759Found a 29 line (121 tokens) duplication in the following files:
13760Starting at line 483 of /home/shackle/pggit/postgresql/src/backend/access/common/printtup.c
13761Starting at line 668 of /home/shackle/pggit/postgresql/src/backend/access/common/printtup.c
13762
13763 pq_beginmessage_reuse(buf, 'D');
13764
13765 /*
13766 * send a bitmap of which attributes are not null
13767 */
13768 j = 0;
13769 k = 1 << 7;
13770 for (i = 0; i < natts; ++i)
13771 {
13772 if (!slot->tts_isnull[i])
13773 j |= k; /* set bit if not null */
13774 k >>= 1;
13775 if (k == 0) /* end of byte? */
13776 {
13777 pq_sendint8(buf, j);
13778 j = 0;
13779 k = 1 << 7;
13780 }
13781 }
13782 if (k != (1 << 7)) /* flush last partial byte */
13783 pq_sendint8(buf, j);
13784
13785 /*
13786 * send the attributes of this tuple
13787 */
13788 for (i = 0; i < natts; ++i)
13789 {
13790 PrinttupAttrInfo *thisState = myState->myinfo + i;
13791 Datum attr = slot->tts_values[i];
13792=====================================================================
13793Found a 17 line (120 tokens) duplication in the following files:
13794Starting at line 358 of /home/shackle/pggit/postgresql/contrib/ltree/_ltree_gist.c
13795Starting at line 410 of /home/shackle/pggit/postgresql/contrib/intarray/_intbig_gist.c
13796
13797 memcpy((void *) LTG_SIGN(datum_r), (void *) LTG_SIGN(GETENTRY(entryvec, seed_2)), sizeof(ABITVEC));
13798 }
13799
13800 maxoff = OffsetNumberNext(maxoff);
13801 /* sort before ... */
13802 costvector = (SPLITCOST *) palloc(sizeof(SPLITCOST) * maxoff);
13803 for (j = FirstOffsetNumber; j <= maxoff; j = OffsetNumberNext(j))
13804 {
13805 costvector[j - 1].pos = j;
13806 _j = GETENTRY(entryvec, j);
13807 size_alpha = hemdist(datum_l, _j);
13808 size_beta = hemdist(datum_r, _j);
13809 costvector[j - 1].cost = Abs(size_alpha - size_beta);
13810 }
13811 qsort((void *) costvector, maxoff, sizeof(SPLITCOST), comparecost);
13812
13813 union_l = LTG_SIGN(datum_l);
13814=====================================================================
13815Found a 3 line (120 tokens) duplication in the following files:
13816Starting at line 31 of /home/shackle/pggit/postgresql/src/common/base64.c
13817Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
13818Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
13819Starting at line 207 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
13820Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
13821
13822 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
13823 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
13824 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
13825=====================================================================
13826Found a 3 line (120 tokens) duplication in the following files:
13827Starting at line 31 of /home/shackle/pggit/postgresql/src/common/base64.c
13828Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
13829Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
13830Starting at line 207 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
13831Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
13832
13833 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
13834 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
13835 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
13836=====================================================================
13837Found a 43 line (120 tokens) duplication in the following files:
13838Starting at line 1080 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/numeric.c
13839Starting at line 7641 of /home/shackle/pggit/postgresql/src/backend/utils/adt/numeric.c
13840
13841 int res_dscale;
13842
13843 /*
13844 * The result scale of a division isn't specified in any SQL standard. For
13845 * PostgreSQL we select a display scale that will give at least
13846 * NUMERIC_MIN_SIG_DIGITS significant digits, so that numeric gives a
13847 * result no less accurate than float8; but use a scale not less than
13848 * either input's display scale.
13849 */
13850
13851 /* Get the actual (normalized) weight and first digit of each input */
13852
13853 weight1 = 0; /* values to use if var1 is zero */
13854 firstdigit1 = 0;
13855 for (i = 0; i < var1->ndigits; i++)
13856 {
13857 firstdigit1 = var1->digits[i];
13858 if (firstdigit1 != 0)
13859 {
13860 weight1 = var1->weight - i;
13861 break;
13862 }
13863 }
13864
13865 weight2 = 0; /* values to use if var2 is zero */
13866 firstdigit2 = 0;
13867 for (i = 0; i < var2->ndigits; i++)
13868 {
13869 firstdigit2 = var2->digits[i];
13870 if (firstdigit2 != 0)
13871 {
13872 weight2 = var2->weight - i;
13873 break;
13874 }
13875 }
13876
13877 /*
13878 * Estimate weight of quotient. If the two first digits are equal, we
13879 * can't be sure, but assume that var1 is less than var2.
13880 */
13881 qweight = weight1 - weight2;
13882 if (firstdigit1 <= firstdigit2)
13883 qweight--;
13884=====================================================================
13885Found a 27 line (120 tokens) duplication in the following files:
13886Starting at line 220 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-autoprep.c
13887Starting at line 95 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-parser.c
13888
13889 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur1", ECPGt_EOIT, ECPGt_EORT);
13890#line 60 "autoprep.pgc"
13891
13892if (sqlca.sqlwarn[0] == 'W') sqlprint();
13893#line 60 "autoprep.pgc"
13894
13895if (sqlca.sqlcode < 0) sqlprint();}
13896#line 60 "autoprep.pgc"
13897
13898
13899 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table T", ECPGt_EOIT, ECPGt_EORT);
13900#line 62 "autoprep.pgc"
13901
13902if (sqlca.sqlwarn[0] == 'W') sqlprint();
13903#line 62 "autoprep.pgc"
13904
13905if (sqlca.sqlcode < 0) sqlprint();}
13906#line 62 "autoprep.pgc"
13907
13908
13909 { ECPGdisconnect(__LINE__, "ALL");
13910#line 64 "autoprep.pgc"
13911
13912if (sqlca.sqlwarn[0] == 'W') sqlprint();
13913#line 64 "autoprep.pgc"
13914
13915if (sqlca.sqlcode < 0) sqlprint();}
13916=====================================================================
13917Found a 23 line (120 tokens) duplication in the following files:
13918Starting at line 474 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-sqlda.c
13919Starting at line 462 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c
13920
13921 { ECPGdo(__LINE__, 0, 1, "con2", 0, ECPGst_execute, "st_id4",
13922 ECPGt_sqlda, &inp_sqlda, 0L, 0L, 0L,
13923 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
13924 ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L,
13925 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
13926#line 234 "sqlda.pgc"
13927
13928if (sqlca.sqlcode < 0) exit (1);}
13929#line 234 "sqlda.pgc"
13930
13931
13932 dump_sqlda(outp_sqlda);
13933
13934 strcpy(msg, "commit");
13935 { ECPGtrans(__LINE__, "con2", "commit");
13936#line 239 "sqlda.pgc"
13937
13938if (sqlca.sqlcode < 0) exit (1);}
13939#line 239 "sqlda.pgc"
13940
13941
13942 strcpy(msg, "deallocate");
13943 { ECPGdeallocate(__LINE__, 0, NULL, "st_id4");
13944=====================================================================
13945Found a 16 line (120 tokens) duplication in the following files:
13946Starting at line 261 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/compat_informix-describe.c
13947Starting at line 259 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-describe.c
13948Starting at line 220 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-describe.c
13949Starting at line 382 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-describe.c
13950
13951 for (i = 1; i <= count1; i++)
13952 {
13953 { ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
13954 ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
13955
13956#line 115 "describe.pgc"
13957
13958if (sqlca.sqlcode < 0) exit (1);}
13959#line 115 "describe.pgc"
13960
13961 { ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
13962 ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
13963
13964#line 116 "describe.pgc"
13965
13966if (sqlca.sqlcode < 0) exit (1);}
13967=====================================================================
13968Found a 5 line (120 tokens) duplication in the following files:
13969Starting at line 98 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
13970Starting at line 103 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
13971
13972 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
13973 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
13974 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
13975 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
13976 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
13977=====================================================================
13978Found a 16 line (120 tokens) duplication in the following files:
13979Starting at line 923 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
13980Starting at line 1243 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
13981Starting at line 1553 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
13982
13983 InitFunctionCallInfoData(fcinfo, NULL, 6, collation, NULL, NULL);
13984
13985 fcinfo.arg[0] = arg1;
13986 fcinfo.arg[1] = arg2;
13987 fcinfo.arg[2] = arg3;
13988 fcinfo.arg[3] = arg4;
13989 fcinfo.arg[4] = arg5;
13990 fcinfo.arg[5] = arg6;
13991 fcinfo.argnull[0] = false;
13992 fcinfo.argnull[1] = false;
13993 fcinfo.argnull[2] = false;
13994 fcinfo.argnull[3] = false;
13995 fcinfo.argnull[4] = false;
13996 fcinfo.argnull[5] = false;
13997
13998 result = (*func) (&fcinfo);
13999=====================================================================
14000Found a 31 line (120 tokens) duplication in the following files:
14001Starting at line 883 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
14002Starting at line 1127 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
14003Starting at line 1386 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
14004Starting at line 1630 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
14005
14006 Oid collation;
14007
14008 /*
14009 * Skip dropped columns
14010 */
14011 if (i1 < ncolumns1 && TupleDescAttr(tupdesc1, i1)->attisdropped)
14012 {
14013 i1++;
14014 continue;
14015 }
14016 if (i2 < ncolumns2 && TupleDescAttr(tupdesc2, i2)->attisdropped)
14017 {
14018 i2++;
14019 continue;
14020 }
14021 if (i1 >= ncolumns1 || i2 >= ncolumns2)
14022 break; /* we'll deal with mismatch below loop */
14023
14024 att1 = TupleDescAttr(tupdesc1, i1);
14025 att2 = TupleDescAttr(tupdesc2, i2);
14026
14027 /*
14028 * Have two matching columns, they must be same type
14029 */
14030 if (att1->atttypid != att2->atttypid)
14031 ereport(ERROR,
14032 (errcode(ERRCODE_DATATYPE_MISMATCH),
14033 errmsg("cannot compare dissimilar column types %s and %s at record column %d",
14034 format_type_be(att1->atttypid),
14035 format_type_be(att2->atttypid),
14036 j + 1)));
14037=====================================================================
14038Found a 24 line (119 tokens) duplication in the following files:
14039Starting at line 375 of /home/shackle/pggit/postgresql/contrib/ltree/_ltree_gist.c
14040Starting at line 427 of /home/shackle/pggit/postgresql/contrib/intarray/_intbig_gist.c
14041
14042 union_r = LTG_SIGN(datum_r);
14043
14044 for (k = 0; k < maxoff; k++)
14045 {
14046 j = costvector[k].pos;
14047 if (j == seed_1)
14048 {
14049 *left++ = j;
14050 v->spl_nleft++;
14051 continue;
14052 }
14053 else if (j == seed_2)
14054 {
14055 *right++ = j;
14056 v->spl_nright++;
14057 continue;
14058 }
14059 _j = GETENTRY(entryvec, j);
14060 size_alpha = hemdist(datum_l, _j);
14061 size_beta = hemdist(datum_r, _j);
14062
14063 if (size_alpha < size_beta + WISH_F(v->spl_nleft, v->spl_nright, 0.00001))
14064 {
14065 if (LTG_ISALLTRUE(datum_l) || LTG_ISALLTRUE(_j))
14066=====================================================================
14067Found a 18 line (119 tokens) duplication in the following files:
14068Starting at line 18 of /home/shackle/pggit/postgresql/src/bin/scripts/dropuser.c
14069Starting at line 18 of /home/shackle/pggit/postgresql/src/bin/scripts/dropdb.c
14070
14071static void help(const char *progname);
14072
14073
14074int
14075main(int argc, char *argv[])
14076{
14077 static int if_exists = 0;
14078
14079 static struct option long_options[] = {
14080 {"host", required_argument, NULL, 'h'},
14081 {"port", required_argument, NULL, 'p'},
14082 {"username", required_argument, NULL, 'U'},
14083 {"no-password", no_argument, NULL, 'w'},
14084 {"password", no_argument, NULL, 'W'},
14085 {"echo", no_argument, NULL, 'e'},
14086 {"interactive", no_argument, NULL, 'i'},
14087 {"if-exists", no_argument, &if_exists, 1},
14088 {NULL, 0, NULL, 0}
14089=====================================================================
14090Found a 31 line (119 tokens) duplication in the following files:
14091Starting at line 1376 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-protocol2.c
14092Starting at line 1867 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-protocol3.c
14093
14094 resetPQExpBuffer(&conn->errorMessage);
14095
14096 /* Wait for the completion response */
14097 result = PQgetResult(conn);
14098
14099 /* Expecting a successful result */
14100 if (result && result->resultStatus == PGRES_COMMAND_OK)
14101 {
14102 PQclear(result);
14103 return 0;
14104 }
14105
14106 /*
14107 * Trouble. For backwards-compatibility reasons, we issue the error
14108 * message as if it were a notice (would be nice to get rid of this
14109 * silliness, but too many apps probably don't handle errors from
14110 * PQendcopy reasonably). Note that the app can still obtain the error
14111 * status from the PGconn object.
14112 */
14113 if (conn->errorMessage.len > 0)
14114 {
14115 /* We have to strip the trailing newline ... pain in neck... */
14116 char svLast = conn->errorMessage.data[conn->errorMessage.len - 1];
14117
14118 if (svLast == '\n')
14119 conn->errorMessage.data[conn->errorMessage.len - 1] = '\0';
14120 pqInternalNotice(&conn->noticeHooks, "%s", conn->errorMessage.data);
14121 conn->errorMessage.data[conn->errorMessage.len - 1] = svLast;
14122 }
14123
14124 PQclear(result);
14125=====================================================================
14126Found a 40 line (119 tokens) duplication in the following files:
14127Starting at line 119 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-describe.c
14128Starting at line 284 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-describe.c
14129
14130 { ECPGtrans(__LINE__, NULL, "commit");
14131#line 41 "describe.pgc"
14132
14133if (sqlca.sqlcode < 0) exit (1);}
14134#line 41 "describe.pgc"
14135
14136
14137 /*
14138 * Test DESCRIBE with a query producing tuples.
14139 * DESCRIPTOR and SQL DESCRIPTOR are the same in native mode.
14140 */
14141
14142 strcpy(msg, "allocate");
14143 ECPGallocate_desc(__LINE__, "desc1");
14144#line 49 "describe.pgc"
14145
14146if (sqlca.sqlcode < 0) exit (1);
14147#line 49 "describe.pgc"
14148
14149 ECPGallocate_desc(__LINE__, "desc2");
14150#line 50 "describe.pgc"
14151
14152if (sqlca.sqlcode < 0) exit (1);
14153#line 50 "describe.pgc"
14154
14155 ECPGallocate_desc(__LINE__, "desc3");
14156#line 51 "describe.pgc"
14157
14158if (sqlca.sqlcode < 0) exit (1);
14159#line 51 "describe.pgc"
14160
14161 ECPGallocate_desc(__LINE__, "desc4");
14162#line 52 "describe.pgc"
14163
14164if (sqlca.sqlcode < 0) exit (1);
14165#line 52 "describe.pgc"
14166
14167
14168 strcpy(msg, "prepare");
14169 { ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1);
14170=====================================================================
14171Found a 18 line (119 tokens) duplication in the following files:
14172Starting at line 773 of /home/shackle/pggit/postgresql/src/backend/utils/adt/ri_triggers.c
14173Starting at line 913 of /home/shackle/pggit/postgresql/src/backend/utils/adt/ri_triggers.c
14174
14175 appendStringInfo(&querybuf, "SELECT 1 FROM %s%s x",
14176 fk_only, fkrelname);
14177 querysep = "WHERE";
14178 for (i = 0; i < riinfo->nkeys; i++)
14179 {
14180 Oid pk_type = RIAttType(pk_rel, riinfo->pk_attnums[i]);
14181 Oid fk_type = RIAttType(fk_rel, riinfo->fk_attnums[i]);
14182
14183 quoteOneName(attname,
14184 RIAttName(fk_rel, riinfo->fk_attnums[i]));
14185 sprintf(paramname, "$%d", i + 1);
14186 ri_GenerateQual(&querybuf, querysep,
14187 paramname, pk_type,
14188 riinfo->pf_eq_oprs[i],
14189 attname, fk_type);
14190 querysep = "AND";
14191 queryoids[i] = pk_type;
14192 }
14193=====================================================================
14194Found a 30 line (119 tokens) duplication in the following files:
14195Starting at line 3996 of /home/shackle/pggit/postgresql/src/backend/access/transam/xact.c
14196Starting at line 4105 of /home/shackle/pggit/postgresql/src/backend/access/transam/xact.c
14197
14198 elog(FATAL, "ReleaseSavepoint: unexpected state %s",
14199 BlockStateAsString(s->blockState));
14200 break;
14201 }
14202
14203 for (target = s; PointerIsValid(target); target = target->parent)
14204 {
14205 if (PointerIsValid(target->name) && strcmp(target->name, name) == 0)
14206 break;
14207 }
14208
14209 if (!PointerIsValid(target))
14210 ereport(ERROR,
14211 (errcode(ERRCODE_S_E_INVALID_SPECIFICATION),
14212 errmsg("savepoint \"%s\" does not exist", name)));
14213
14214 /* disallow crossing savepoint level boundaries */
14215 if (target->savepointLevel != s->savepointLevel)
14216 ereport(ERROR,
14217 (errcode(ERRCODE_S_E_INVALID_SPECIFICATION),
14218 errmsg("savepoint \"%s\" does not exist within current savepoint level", name)));
14219
14220 /*
14221 * Mark "commit pending" all subtransactions up to the target
14222 * subtransaction. The actual commits will happen when control gets to
14223 * CommitTransactionCommand.
14224 */
14225 xact = CurrentTransactionState;
14226 for (;;)
14227 {
14228=====================================================================
14229Found a 34 line (118 tokens) duplication in the following files:
14230Starting at line 5051 of /home/shackle/pggit/postgresql/src/pl/plpgsql/src/pl_exec.c
14231Starting at line 5417 of /home/shackle/pggit/postgresql/src/pl/plpgsql/src/pl_exec.c
14232
14233 PLpgSQL_recfield *recfield = (PLpgSQL_recfield *) target;
14234 PLpgSQL_rec *rec;
14235 ExpandedRecordHeader *erh;
14236
14237 rec = (PLpgSQL_rec *) (estate->datums[recfield->recparentno]);
14238 erh = rec->erh;
14239
14240 /*
14241 * If record variable is NULL, instantiate it if it has a
14242 * named composite type, else complain. (This won't change
14243 * the logical state of the record, but if we successfully
14244 * assign below, the unassigned fields will all become NULLs.)
14245 */
14246 if (erh == NULL)
14247 {
14248 instantiate_empty_record_variable(estate, rec);
14249 erh = rec->erh;
14250 }
14251
14252 /*
14253 * Look up the field's properties if we have not already, or
14254 * if the tuple descriptor ID changed since last time.
14255 */
14256 if (unlikely(recfield->rectupledescid != erh->er_tupdesc_id))
14257 {
14258 if (!expanded_record_lookup_field(erh,
14259 recfield->fieldname,
14260 &recfield->finfo))
14261 ereport(ERROR,
14262 (errcode(ERRCODE_UNDEFINED_COLUMN),
14263 errmsg("record \"%s\" has no field \"%s\"",
14264 rec->refname, recfield->fieldname)));
14265 recfield->rectupledescid = erh->er_tupdesc_id;
14266 }
14267=====================================================================
14268Found a 24 line (118 tokens) duplication in the following files:
14269Starting at line 3745 of /home/shackle/pggit/postgresql/src/pl/plperl/plperl.c
14270Starting at line 3858 of /home/shackle/pggit/postgresql/src/pl/plperl/plperl.c
14271
14272 if (argc > 0)
14273 {
14274 nulls = (char *) palloc(argc);
14275 argvalues = (Datum *) palloc(argc * sizeof(Datum));
14276 }
14277 else
14278 {
14279 nulls = NULL;
14280 argvalues = NULL;
14281 }
14282
14283 for (i = 0; i < argc; i++)
14284 {
14285 bool isnull;
14286
14287 argvalues[i] = plperl_sv_to_datum(argv[i],
14288 qdesc->argtypes[i],
14289 -1,
14290 NULL,
14291 &qdesc->arginfuncs[i],
14292 qdesc->argtypioparams[i],
14293 &isnull);
14294 nulls[i] = isnull ? 'n' : ' ';
14295 }
14296=====================================================================
14297Found a 18 line (118 tokens) duplication in the following files:
14298Starting at line 569 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/numeric.c
14299Starting at line 657 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/numeric.c
14300
14301 res_weight = Max(var1->weight, var2->weight) + 1;
14302 res_rscale = Max(var1->rscale, var2->rscale);
14303 res_dscale = Max(var1->dscale, var2->dscale);
14304 res_ndigits = res_rscale + res_weight + 1;
14305 if (res_ndigits <= 0)
14306 res_ndigits = 1;
14307
14308 if ((res_buf = digitbuf_alloc(res_ndigits)) == NULL)
14309 return -1;
14310 res_digits = res_buf;
14311
14312 i1 = res_rscale + var1->weight + 1;
14313 i2 = res_rscale + var2->weight + 1;
14314 for (i = res_ndigits - 1; i >= 0; i--)
14315 {
14316 i1--;
14317 i2--;
14318 if (i1 >= 0 && i1 < var1ndigits)
14319=====================================================================
14320Found a 27 line (118 tokens) duplication in the following files:
14321Starting at line 119 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-variable.c
14322Starting at line 269 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-outofscope.c
14323Starting at line 76 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-describe.c
14324Starting at line 59 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-describe.c
14325
14326 ind children ;
14327
14328#line 37 "variable.pgc"
14329
14330
14331 char msg[128];
14332
14333 ECPGdebug(1, stderr);
14334
14335 strcpy(msg, "connect");
14336 { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0);
14337#line 44 "variable.pgc"
14338
14339if (sqlca.sqlcode < 0) exit (1);}
14340#line 44 "variable.pgc"
14341
14342
14343 strcpy(msg, "set");
14344 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
14345#line 47 "variable.pgc"
14346
14347if (sqlca.sqlcode < 0) exit (1);}
14348#line 47 "variable.pgc"
14349
14350
14351 strcpy(msg, "create");
14352 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table family ( name char ( 8 ) , born integer , age smallint , married date , children integer )", ECPGt_EOIT, ECPGt_EORT);
14353=====================================================================
14354Found a 10 line (118 tokens) duplication in the following files:
14355Starting at line 191 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.c
14356Starting at line 234 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.c
14357
14358 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select id , d , d from nantest2 where id = 4", ECPGt_EOIT,
14359 ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
14360 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
14361 ECPGt_numeric,&(num),(long)1,(long)0,sizeof(numeric),
14362 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
14363 ECPGt_char,(val),(long)16,(long)1,(16)*sizeof(char),
14364 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
14365#line 70 "nan_test.pgc"
14366
14367if (sqlca.sqlcode < 0) sqlprint ( );}
14368=====================================================================
14369Found a 5 line (118 tokens) duplication in the following files:
14370Starting at line 98 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
14371Starting at line 103 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
14372
14373 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
14374 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
14375 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
14376 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
14377 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
14378=====================================================================
14379Found a 36 line (118 tokens) duplication in the following files:
14380Starting at line 816 of /home/shackle/pggit/postgresql/src/backend/utils/mmgr/mcxt.c
14381Starting at line 959 of /home/shackle/pggit/postgresql/src/backend/utils/mmgr/mcxt.c
14382
14383 void *ret;
14384
14385 AssertArg(MemoryContextIsValid(context));
14386 AssertNotInCriticalSection(context);
14387
14388 if (!AllocSizeIsValid(size))
14389 elog(ERROR, "invalid memory alloc request size %zu", size);
14390
14391 context->isReset = false;
14392
14393 ret = context->methods->alloc(context, size);
14394 if (unlikely(ret == NULL))
14395 {
14396 MemoryContextStats(TopMemoryContext);
14397 ereport(ERROR,
14398 (errcode(ERRCODE_OUT_OF_MEMORY),
14399 errmsg("out of memory"),
14400 errdetail("Failed on request of size %zu in memory context \"%s\".",
14401 size, context->name)));
14402 }
14403
14404 VALGRIND_MEMPOOL_ALLOC(context, ret, size);
14405
14406 MemSetAligned(ret, 0, size);
14407
14408 return ret;
14409}
14410
14411/*
14412 * MemoryContextAllocZeroAligned
14413 * MemoryContextAllocZero where length is suitable for MemSetLoop
14414 *
14415 * This might seem overly specialized, but it's not because newNode()
14416 * is so often called with compile-time-constant sizes.
14417 */
14418void *
14419=====================================================================
14420Found a 24 line (118 tokens) duplication in the following files:
14421Starting at line 415 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c
14422Starting at line 197 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/euc_tw_and_big5.c
14423Starting at line 106 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/euc_kr_and_mic/euc_kr_and_mic.c
14424
14425mic2euc_jp(const unsigned char *mic, unsigned char *p, int len)
14426{
14427 int c1;
14428 int l;
14429
14430 while (len > 0)
14431 {
14432 c1 = *mic;
14433 if (!IS_HIGHBIT_SET(c1))
14434 {
14435 /* ASCII */
14436 if (c1 == 0)
14437 report_invalid_encoding(PG_MULE_INTERNAL,
14438 (const char *) mic, len);
14439 *p++ = c1;
14440 mic++;
14441 len--;
14442 continue;
14443 }
14444 l = pg_encoding_verifymb(PG_MULE_INTERNAL, (const char *) mic, len);
14445 if (l < 0)
14446 report_invalid_encoding(PG_MULE_INTERNAL,
14447 (const char *) mic, len);
14448 if (c1 == LC_JISX0201K)
14449=====================================================================
14450Found a 20 line (118 tokens) duplication in the following files:
14451Starting at line 3886 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
14452Starting at line 4017 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
14453
14454 str = pg_ltostr_zeropad(str, tm->tm_mday, 2);
14455 break;
14456
14457 case USE_SQL_DATES:
14458 /* compatible with Oracle/Ingres date formats */
14459 if (DateOrder == DATEORDER_DMY)
14460 {
14461 str = pg_ltostr_zeropad(str, tm->tm_mday, 2);
14462 *str++ = '/';
14463 str = pg_ltostr_zeropad(str, tm->tm_mon, 2);
14464 }
14465 else
14466 {
14467 str = pg_ltostr_zeropad(str, tm->tm_mon, 2);
14468 *str++ = '/';
14469 str = pg_ltostr_zeropad(str, tm->tm_mday, 2);
14470 }
14471 *str++ = '/';
14472 str = pg_ltostr_zeropad(str,
14473 (tm->tm_year > 0) ? tm->tm_year : -(tm->tm_year - 1), 4);
14474=====================================================================
14475Found a 3 line (117 tokens) duplication in the following files:
14476Starting at line 31 of /home/shackle/pggit/postgresql/src/common/base64.c
14477Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
14478Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
14479Starting at line 207 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
14480Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
14481
14482 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
14483 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
14484 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
14485=====================================================================
14486Found a 3 line (117 tokens) duplication in the following files:
14487Starting at line 31 of /home/shackle/pggit/postgresql/src/common/base64.c
14488Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
14489Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
14490Starting at line 207 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
14491Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
14492
14493 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
14494 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
14495 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
14496=====================================================================
14497Found a 26 line (117 tokens) duplication in the following files:
14498Starting at line 864 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/ecpglib/execute.c
14499Starting at line 911 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/ecpglib/execute.c
14500Starting at line 958 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/ecpglib/execute.c
14501Starting at line 1005 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/ecpglib/execute.c
14502
14503 PGTYPESnumeric_free(nval);
14504
14505 if (!(newcopy = ecpg_realloc(mallocedval, strlen(mallocedval) + slen + 2, lineno)))
14506 {
14507 ecpg_free(mallocedval);
14508 ecpg_free(str);
14509 return false;
14510 }
14511 mallocedval = newcopy;
14512
14513 /* also copy trailing '\0' */
14514 memcpy(mallocedval + strlen(mallocedval), str, slen + 1);
14515 if (var->arrsize > 1)
14516 strcpy(mallocedval + strlen(mallocedval), ",");
14517
14518 ecpg_free(str);
14519 }
14520
14521 if (var->arrsize > 1)
14522 strcpy(mallocedval + strlen(mallocedval) - 1, "}");
14523
14524 *tobeinserted_p = mallocedval;
14525 }
14526 break;
14527
14528 case ECPGt_interval:
14529=====================================================================
14530Found a 29 line (117 tokens) duplication in the following files:
14531Starting at line 451 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/interval.c
14532Starting at line 3211 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
14533
14534 val2 = -val2;
14535 val = val * MONTHS_PER_YEAR + val2;
14536 fval = 0;
14537 }
14538 else if (*cp == '.')
14539 {
14540 errno = 0;
14541 fval = strtod(cp, &cp);
14542 if (*cp != '\0' || errno != 0)
14543 return DTERR_BAD_FORMAT;
14544
14545 if (*field[i] == '-')
14546 fval = -fval;
14547 }
14548 else if (*cp == '\0')
14549 fval = 0;
14550 else
14551 return DTERR_BAD_FORMAT;
14552
14553 tmask = 0; /* DTK_M(type); */
14554
14555 switch (type)
14556 {
14557 case DTK_MICROSEC:
14558 *fsec += rint(val + fval);
14559 tmask = DTK_M(MICROSECOND);
14560 break;
14561
14562 case DTK_MILLISEC:
14563=====================================================================
14564Found a 9 line (117 tokens) duplication in the following files:
14565Starting at line 201 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
14566Starting at line 216 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
14567Starting at line 231 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
14568Starting at line 249 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
14569Starting at line 274 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
14570Starting at line 292 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
14571Starting at line 327 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
14572Starting at line 404 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
14573Starting at line 509 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
14574Starting at line 524 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
14575Starting at line 539 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
14576Starting at line 557 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
14577Starting at line 582 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
14578Starting at line 600 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
14579
14580 ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
14581 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
14582 ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
14583 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
14584 ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
14585 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
14586#line 70 "cursor.pgc"
14587
14588if (sqlca.sqlcode < 0) exit (1);}
14589=====================================================================
14590Found a 15 line (117 tokens) duplication in the following files:
14591Starting at line 68 of /home/shackle/pggit/postgresql/src/backend/regex/rege_dfa.c
14592Starting at line 197 of /home/shackle/pggit/postgresql/src/backend/regex/rege_dfa.c
14593
14594 FDEBUG(("+++ startup +++\n"));
14595 if (cp == v->start)
14596 {
14597 co = d->cnfa->bos[(v->eflags & REG_NOTBOL) ? 0 : 1];
14598 FDEBUG(("color %ld\n", (long) co));
14599 }
14600 else
14601 {
14602 co = GETCOLOR(cm, *(cp - 1));
14603 FDEBUG(("char %c, color %ld\n", (char) *(cp - 1), (long) co));
14604 }
14605 css = miss(v, d, css, co, cp, start);
14606 if (css == NULL)
14607 return NULL;
14608 css->lastseen = cp;
14609=====================================================================
14610Found a 36 line (117 tokens) duplication in the following files:
14611Starting at line 504 of /home/shackle/pggit/postgresql/src/backend/catalog/dependency.c
14612Starting at line 1042 of /home/shackle/pggit/postgresql/src/backend/catalog/dependency.c
14613
14614 return;
14615
14616 /*
14617 * The target object might be internally dependent on some other object
14618 * (its "owner"), and/or be a member of an extension (also considered its
14619 * owner). If so, and if we aren't recursing from the owning object, we
14620 * have to transform this deletion request into a deletion request of the
14621 * owning object. (We'll eventually recurse back to this object, but the
14622 * owning object has to be visited first so it will be deleted after.) The
14623 * way to find out about this is to scan the pg_depend entries that show
14624 * what this object depends on.
14625 */
14626 ScanKeyInit(&key[0],
14627 Anum_pg_depend_classid,
14628 BTEqualStrategyNumber, F_OIDEQ,
14629 ObjectIdGetDatum(object->classId));
14630 ScanKeyInit(&key[1],
14631 Anum_pg_depend_objid,
14632 BTEqualStrategyNumber, F_OIDEQ,
14633 ObjectIdGetDatum(object->objectId));
14634 if (object->objectSubId != 0)
14635 {
14636 ScanKeyInit(&key[2],
14637 Anum_pg_depend_objsubid,
14638 BTEqualStrategyNumber, F_INT4EQ,
14639 Int32GetDatum(object->objectSubId));
14640 nkeys = 3;
14641 }
14642 else
14643 nkeys = 2;
14644
14645 scan = systable_beginscan(*depRel, DependDependerIndexId, true,
14646 NULL, nkeys, key);
14647
14648 while (HeapTupleIsValid(tup = systable_getnext(scan)))
14649 {
14650=====================================================================
14651Found a 24 line (117 tokens) duplication in the following files:
14652Starting at line 1020 of /home/shackle/pggit/postgresql/src/backend/utils/adt/tsvector_op.c
14653Starting at line 1102 of /home/shackle/pggit/postgresql/src/backend/utils/adt/tsvector_op.c
14654
14655 else if (cmp > 0)
14656 { /* in2 first */
14657 ptr->haspos = ptr2->haspos;
14658 ptr->len = ptr2->len;
14659 memcpy(data + dataoff, data2 + ptr2->pos, ptr2->len);
14660 ptr->pos = dataoff;
14661 dataoff += ptr2->len;
14662 if (ptr->haspos)
14663 {
14664 int addlen = add_pos(in2, ptr2, out, ptr, maxpos);
14665
14666 if (addlen == 0)
14667 ptr->haspos = 0;
14668 else
14669 {
14670 dataoff = SHORTALIGN(dataoff);
14671 dataoff += addlen * sizeof(WordEntryPos) + sizeof(uint16);
14672 }
14673 }
14674
14675 ptr++;
14676 ptr2++;
14677 i2--;
14678 }
14679=====================================================================
14680Found a 28 line (117 tokens) duplication in the following files:
14681Starting at line 10447 of /home/shackle/pggit/postgresql/src/backend/commands/tablecmds.c
14682Starting at line 12970 of /home/shackle/pggit/postgresql/src/backend/commands/tablecmds.c
14683
14684 ObjectIdGetDatum(relationOid));
14685 /* we leave refobjsubid unspecified */
14686
14687 scan = systable_beginscan(depRel, DependReferenceIndexId, true,
14688 NULL, 2, key);
14689
14690 while (HeapTupleIsValid(tup = systable_getnext(scan)))
14691 {
14692 Form_pg_depend depForm = (Form_pg_depend) GETSTRUCT(tup);
14693 Relation seqRel;
14694
14695 /* skip dependencies other than auto dependencies on columns */
14696 if (depForm->refobjsubid == 0 ||
14697 depForm->classid != RelationRelationId ||
14698 depForm->objsubid != 0 ||
14699 !(depForm->deptype == DEPENDENCY_AUTO || depForm->deptype == DEPENDENCY_INTERNAL))
14700 continue;
14701
14702 /* Use relation_open just in case it's an index */
14703 seqRel = relation_open(depForm->objid, lockmode);
14704
14705 /* skip non-sequence relations */
14706 if (RelationGetForm(seqRel)->relkind != RELKIND_SEQUENCE)
14707 {
14708 /* No need to keep the lock */
14709 relation_close(seqRel, lockmode);
14710 continue;
14711 }
14712=====================================================================
14713Found a 27 line (116 tokens) duplication in the following files:
14714Starting at line 2146 of /home/shackle/pggit/postgresql/contrib/dblink/dblink.c
14715Starting at line 2263 of /home/shackle/pggit/postgresql/contrib/dblink/dblink.c
14716
14717get_sql_insert(Relation rel, int *pkattnums, int pknumatts, char **src_pkattvals, char **tgt_pkattvals)
14718{
14719 char *relname;
14720 HeapTuple tuple;
14721 TupleDesc tupdesc;
14722 int natts;
14723 StringInfoData buf;
14724 char *val;
14725 int key;
14726 int i;
14727 bool needComma;
14728
14729 initStringInfo(&buf);
14730
14731 /* get relation name including any needed schema prefix and quoting */
14732 relname = generate_relation_name(rel);
14733
14734 tupdesc = rel->rd_att;
14735 natts = tupdesc->natts;
14736
14737 tuple = get_tuple_of_interest(rel, pkattnums, pknumatts, src_pkattvals);
14738 if (!tuple)
14739 ereport(ERROR,
14740 (errcode(ERRCODE_CARDINALITY_VIOLATION),
14741 errmsg("source row not found")));
14742
14743 appendStringInfo(&buf, "INSERT INTO %s(", relname);
14744=====================================================================
14745Found a 10 line (116 tokens) duplication in the following files:
14746Starting at line 52 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_backup_tar.c
14747Starting at line 77 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_backup_directory.c
14748
14749static void _CloseArchive(ArchiveHandle *AH);
14750static void _PrintTocData(ArchiveHandle *AH, TocEntry *te);
14751static void _WriteExtraToc(ArchiveHandle *AH, TocEntry *te);
14752static void _ReadExtraToc(ArchiveHandle *AH, TocEntry *te);
14753static void _PrintExtraToc(ArchiveHandle *AH, TocEntry *te);
14754
14755static void _StartBlobs(ArchiveHandle *AH, TocEntry *te);
14756static void _StartBlob(ArchiveHandle *AH, TocEntry *te, Oid oid);
14757static void _EndBlob(ArchiveHandle *AH, TocEntry *te, Oid oid);
14758static void _EndBlobs(ArchiveHandle *AH, TocEntry *te);
14759=====================================================================
14760Found a 5 line (116 tokens) duplication in the following files:
14761Starting at line 98 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
14762Starting at line 103 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
14763
14764 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
14765 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
14766 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
14767 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
14768 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
14769=====================================================================
14770Found a 26 line (116 tokens) duplication in the following files:
14771Starting at line 924 of /home/shackle/pggit/postgresql/src/backend/utils/mmgr/mcxt.c
14772Starting at line 955 of /home/shackle/pggit/postgresql/src/backend/utils/mmgr/mcxt.c
14773
14774palloc(Size size)
14775{
14776 /* duplicates MemoryContextAlloc to avoid increased overhead */
14777 void *ret;
14778 MemoryContext context = CurrentMemoryContext;
14779
14780 AssertArg(MemoryContextIsValid(context));
14781 AssertNotInCriticalSection(context);
14782
14783 if (!AllocSizeIsValid(size))
14784 elog(ERROR, "invalid memory alloc request size %zu", size);
14785
14786 context->isReset = false;
14787
14788 ret = context->methods->alloc(context, size);
14789 if (unlikely(ret == NULL))
14790 {
14791 MemoryContextStats(TopMemoryContext);
14792 ereport(ERROR,
14793 (errcode(ERRCODE_OUT_OF_MEMORY),
14794 errmsg("out of memory"),
14795 errdetail("Failed on request of size %zu in memory context \"%s\".",
14796 size, context->name)));
14797 }
14798
14799 VALGRIND_MEMPOOL_ALLOC(context, ret, size);
14800=====================================================================
14801Found a 22 line (116 tokens) duplication in the following files:
14802Starting at line 704 of /home/shackle/pggit/postgresql/src/backend/jit/llvm/llvmjit_expr.c
14803Starting at line 806 of /home/shackle/pggit/postgresql/src/backend/jit/llvm/llvmjit_expr.c
14804
14805 "b.%d.boolisfalse", i);
14806 b_boolisanynull = l_bb_before_v(opblocks[i + 1],
14807 "b.%d.boolisanynull", i);
14808 b_boolcont = l_bb_before_v(opblocks[i + 1],
14809 "b.%d.boolcont", i);
14810
14811 v_boolanynullp = l_ptr_const(op->d.boolexpr.anynull,
14812 l_ptr(TypeStorageBool));
14813
14814 v_boolnull = LLVMBuildLoad(b, v_resnullp, "");
14815 v_boolvalue = LLVMBuildLoad(b, v_resvaluep, "");
14816
14817 /* set resnull to boolnull */
14818 LLVMBuildStore(b, v_boolnull, v_resnullp);
14819 /* set revalue to boolvalue */
14820 LLVMBuildStore(b, v_boolvalue, v_resvaluep);
14821
14822 /* check if current input is NULL */
14823 LLVMBuildCondBr(b,
14824 LLVMBuildICmp(b, LLVMIntEQ, v_boolnull,
14825 l_sbool_const(1), ""),
14826 b_boolisnull,
14827=====================================================================
14828Found a 27 line (115 tokens) duplication in the following files:
14829Starting at line 945 of /home/shackle/pggit/postgresql/src/pl/plpgsql/src/pl_exec.c
14830Starting at line 1106 of /home/shackle/pggit/postgresql/src/pl/plpgsql/src/pl_exec.c
14831
14832 exec_set_found(&estate, false);
14833
14834 /*
14835 * Let the instrumentation plugin peek at this function
14836 */
14837 if (*plpgsql_plugin_ptr && (*plpgsql_plugin_ptr)->func_beg)
14838 ((*plpgsql_plugin_ptr)->func_beg) (&estate, func);
14839
14840 /*
14841 * Now call the toplevel block of statements
14842 */
14843 estate.err_text = NULL;
14844 estate.err_stmt = (PLpgSQL_stmt *) (func->action);
14845 rc = exec_stmt_block(&estate, func->action);
14846 if (rc != PLPGSQL_RC_RETURN)
14847 {
14848 estate.err_stmt = NULL;
14849 estate.err_text = NULL;
14850 ereport(ERROR,
14851 (errcode(ERRCODE_S_R_E_FUNCTION_EXECUTED_NO_RETURN_STATEMENT),
14852 errmsg("control reached end of trigger procedure without RETURN")));
14853 }
14854
14855 estate.err_stmt = NULL;
14856 estate.err_text = gettext_noop("during function exit");
14857
14858 if (estate.retisset)
14859=====================================================================
14860Found a 29 line (115 tokens) duplication in the following files:
14861Starting at line 698 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/interval.c
14862Starting at line 4161 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
14863
14864 *is_zero = false;
14865 return cp + strlen(cp);
14866}
14867
14868/* copy&pasted from .../src/backend/utils/adt/datetime.c */
14869static char *
14870AddPostgresIntPart(char *cp, int value, const char *units,
14871 bool *is_zero, bool *is_before)
14872{
14873 if (value == 0)
14874 return cp;
14875 sprintf(cp, "%s%s%d %s%s",
14876 (!*is_zero) ? " " : "",
14877 (*is_before && value > 0) ? "+" : "",
14878 value,
14879 units,
14880 (value != 1) ? "s" : "");
14881
14882 /*
14883 * Each nonzero field sets is_before for (only) the next one. This is a
14884 * tad bizarre but it's how it worked before...
14885 */
14886 *is_before = (value < 0);
14887 *is_zero = false;
14888 return cp + strlen(cp);
14889}
14890
14891/* copy&pasted from .../src/backend/utils/adt/datetime.c */
14892static char *
14893=====================================================================
14894Found a 20 line (115 tokens) duplication in the following files:
14895Starting at line 195 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-array_of_struct.c
14896Starting at line 199 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-pointer_to_struct.c
14897
14898 ECPGt_short,&(inds->phone_ind),(long)1,(long)10,sizeof( struct ind ), ECPGt_EORT);
14899#line 64 "array_of_struct.pgc"
14900
14901if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint();
14902#line 64 "array_of_struct.pgc"
14903
14904if (sqlca.sqlwarn[0] == 'W') sqlprint();
14905#line 64 "array_of_struct.pgc"
14906
14907if (sqlca.sqlcode < 0) sqlprint();}
14908#line 64 "array_of_struct.pgc"
14909
14910 printf("\ncusts2:\n");
14911 for (r = 0; r < 2; r++)
14912 {
14913 printf( "name - %s\n", custs2[r].name.arr );
14914 printf( "phone - %d\n", custs2[r].phone );
14915 }
14916
14917 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select * from customers limit 2", ECPGt_EOIT,
14918=====================================================================
14919Found a 11 line (115 tokens) duplication in the following files:
14920Starting at line 2410 of /home/shackle/pggit/postgresql/src/backend/nodes/outfuncs.c
14921Starting at line 3638 of /home/shackle/pggit/postgresql/src/backend/nodes/outfuncs.c
14922
14923 WRITE_UINT_FIELD(ref_relid);
14924 WRITE_INT_FIELD(nkeys);
14925 appendStringInfoString(str, " :conkey");
14926 for (i = 0; i < node->nkeys; i++)
14927 appendStringInfo(str, " %d", node->conkey[i]);
14928 appendStringInfoString(str, " :confkey");
14929 for (i = 0; i < node->nkeys; i++)
14930 appendStringInfo(str, " %d", node->confkey[i]);
14931 appendStringInfoString(str, " :conpfeqop");
14932 for (i = 0; i < node->nkeys; i++)
14933 appendStringInfo(str, " %u", node->conpfeqop[i]);
14934=====================================================================
14935Found a 21 line (115 tokens) duplication in the following files:
14936Starting at line 221 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c
14937Starting at line 645 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c
14938
14939 *p++ = LC_JISX0212;
14940 c1 -= 0x74;
14941 *p++ = ((c1 & 0x3f) << 1) + 0xf3 + (c2 > 0x9e);
14942 *p++ = c2 + ((c2 > 0x9e) ? 2 : 0x60) + (c2 < 0x80);
14943 }
14944 else if (k >= 0xfa40)
14945 {
14946 /*
14947 * mapping IBM kanji to X0208 and X0212
14948 */
14949 for (i = 0;; i++)
14950 {
14951 k2 = ibmkanji[i].sjis;
14952 if (k2 == 0xffff)
14953 break;
14954 if (k2 == k)
14955 {
14956 k = ibmkanji[i].euc;
14957 if (k >= 0x8f0000)
14958 {
14959 *p++ = LC_JISX0212;
14960=====================================================================
14961Found a 10 line (115 tokens) duplication in the following files:
14962Starting at line 1737 of /home/shackle/pggit/postgresql/src/backend/utils/mb/wchar.c
14963Starting at line 1756 of /home/shackle/pggit/postgresql/src/backend/utils/mb/wchar.c
14964
14965 {pg_mule2wchar_with_len, pg_wchar2mule_with_len, pg_mule_mblen, pg_mule_dsplen, pg_mule_verifier, 4}, /* PG_MULE_INTERNAL */
14966 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN1 */
14967 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN2 */
14968 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN3 */
14969 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN4 */
14970 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN5 */
14971 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN6 */
14972 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN7 */
14973 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN8 */
14974 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN9 */
14975=====================================================================
14976Found a 5 line (114 tokens) duplication in the following files:
14977Starting at line 83 of /home/shackle/pggit/postgresql/contrib/pgcrypto/crypt-des.c
14978Starting at line 358 of /home/shackle/pggit/postgresql/src/port/crypt.c
14979
14980static uint8 key_perm[56] = {
14981 57, 49, 41, 33, 25, 17, 9, 1, 58, 50, 42, 34, 26, 18,
14982 10, 2, 59, 51, 43, 35, 27, 19, 11, 3, 60, 52, 44, 36,
14983 63, 55, 47, 39, 31, 23, 15, 7, 62, 54, 46, 38, 30, 22,
14984 14, 6, 61, 53, 45, 37, 29, 21, 13, 5, 28, 20, 12, 4
14985=====================================================================
14986Found a 22 line (114 tokens) duplication in the following files:
14987Starting at line 82 of /home/shackle/pggit/postgresql/src/bin/scripts/vacuumdb.c
14988Starting at line 25 of /home/shackle/pggit/postgresql/src/bin/scripts/clusterdb.c
14989
14990static void init_slot(ParallelSlot *slot, PGconn *conn);
14991
14992static void help(const char *progname);
14993
14994/* For analyze-in-stages mode */
14995#define ANALYZE_NO_STAGE -1
14996#define ANALYZE_NUM_STAGES 3
14997
14998
14999int
15000main(int argc, char *argv[])
15001{
15002 static struct option long_options[] = {
15003 {"host", required_argument, NULL, 'h'},
15004 {"port", required_argument, NULL, 'p'},
15005 {"username", required_argument, NULL, 'U'},
15006 {"no-password", no_argument, NULL, 'w'},
15007 {"password", no_argument, NULL, 'W'},
15008 {"echo", no_argument, NULL, 'e'},
15009 {"quiet", no_argument, NULL, 'q'},
15010 {"dbname", required_argument, NULL, 'd'},
15011 {"analyze", no_argument, NULL, 'z'},
15012=====================================================================
15013Found a 3 line (114 tokens) duplication in the following files:
15014Starting at line 31 of /home/shackle/pggit/postgresql/src/common/base64.c
15015Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
15016Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
15017Starting at line 207 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
15018Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
15019
15020 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
15021 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
15022 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
15023=====================================================================
15024Found a 3 line (114 tokens) duplication in the following files:
15025Starting at line 31 of /home/shackle/pggit/postgresql/src/common/base64.c
15026Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
15027Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
15028Starting at line 207 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
15029Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
15030
15031 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
15032 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
15033 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
15034=====================================================================
15035Found a 130 line (114 tokens) duplication in the following files:
15036Starting at line 14 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/thread-prep.c
15037Starting at line 14 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/thread-alloc.c
15038
15039int
15040main(void)
15041{
15042 printf("No threading enabled.\n");
15043 return 0;
15044}
15045#else
15046#ifdef WIN32
15047#define WIN32_LEAN_AND_MEAN
15048#include <windows.h>
15049#include <process.h>
15050#include <locale.h>
15051#else
15052#include <pthread.h>
15053#endif
15054#include <stdio.h>
15055
15056#define THREADS 16
15057#define REPEATS 50
15058
15059
15060#line 1 "sqlca.h"
15061#ifndef POSTGRES_SQLCA_H
15062#define POSTGRES_SQLCA_H
15063
15064#ifndef PGDLLIMPORT
15065#if defined(WIN32) || defined(__CYGWIN__)
15066#define PGDLLIMPORT __declspec (dllimport)
15067#else
15068#define PGDLLIMPORT
15069#endif /* __CYGWIN__ */
15070#endif /* PGDLLIMPORT */
15071
15072#define SQLERRMC_LEN 150
15073
15074#ifdef __cplusplus
15075extern "C"
15076{
15077#endif
15078
15079struct sqlca_t
15080{
15081 char sqlcaid[8];
15082 long sqlabc;
15083 long sqlcode;
15084 struct
15085 {
15086 int sqlerrml;
15087 char sqlerrmc[SQLERRMC_LEN];
15088 } sqlerrm;
15089 char sqlerrp[8];
15090 long sqlerrd[6];
15091 /* Element 0: empty */
15092 /* 1: OID of processed tuple if applicable */
15093 /* 2: number of rows processed */
15094 /* after an INSERT, UPDATE or */
15095 /* DELETE statement */
15096 /* 3: empty */
15097 /* 4: empty */
15098 /* 5: empty */
15099 char sqlwarn[8];
15100 /* Element 0: set to 'W' if at least one other is 'W' */
15101 /* 1: if 'W' at least one character string */
15102 /* value was truncated when it was */
15103 /* stored into a host variable. */
15104
15105 /*
15106 * 2: if 'W' a (hopefully) non-fatal notice occurred
15107 */ /* 3: empty */
15108 /* 4: empty */
15109 /* 5: empty */
15110 /* 6: empty */
15111 /* 7: empty */
15112
15113 char sqlstate[5];
15114};
15115
15116struct sqlca_t *ECPGget_sqlca(void);
15117
15118#ifndef POSTGRES_ECPG_INTERNAL
15119#define sqlca (*ECPGget_sqlca())
15120#endif
15121
15122#ifdef __cplusplus
15123}
15124#endif
15125
15126#endif
15127
15128#line 25 "prep.pgc"
15129
15130
15131#line 1 "regression.h"
15132
15133
15134
15135
15136
15137
15138#line 26 "prep.pgc"
15139
15140
15141/* exec sql whenever sqlerror sqlprint ; */
15142#line 28 "prep.pgc"
15143
15144/* exec sql whenever not found sqlprint ; */
15145#line 29 "prep.pgc"
15146
15147
15148#ifdef WIN32
15149static unsigned __stdcall fn(void* arg)
15150#else
15151static void* fn(void* arg)
15152#endif
15153{
15154 int i;
15155
15156 /* exec sql begin declare section */
15157
15158
15159
15160
15161#line 40 "prep.pgc"
15162 int value ;
15163
15164#line 41 "prep.pgc"
15165 char name [ 100 ] ;
15166
15167#line 42 "prep.pgc"
15168 char query [ 256 ] = "INSERT INTO T VALUES ( ? )" ;
15169=====================================================================
15170Found a 5 line (114 tokens) duplication in the following files:
15171Starting at line 98 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
15172Starting at line 103 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
15173
15174 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
15175 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
15176 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
15177 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
15178 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
15179=====================================================================
15180Found a 26 line (114 tokens) duplication in the following files:
15181Starting at line 450 of /home/shackle/pggit/postgresql/src/backend/catalog/pg_subscription.c
15182Starting at line 502 of /home/shackle/pggit/postgresql/src/backend/catalog/pg_subscription.c
15183
15184 ObjectIdGetDatum(subid));
15185
15186 scan = systable_beginscan(rel, InvalidOid, false,
15187 NULL, nkeys, skey);
15188
15189 while (HeapTupleIsValid(tup = systable_getnext(scan)))
15190 {
15191 Form_pg_subscription_rel subrel;
15192 SubscriptionRelState *relstate;
15193
15194 subrel = (Form_pg_subscription_rel) GETSTRUCT(tup);
15195
15196 relstate = (SubscriptionRelState *) palloc(sizeof(SubscriptionRelState));
15197 relstate->relid = subrel->srrelid;
15198 relstate->state = subrel->srsubstate;
15199 relstate->lsn = subrel->srsublsn;
15200
15201 res = lappend(res, relstate);
15202 }
15203
15204 /* Cleanup */
15205 systable_endscan(scan);
15206 heap_close(rel, AccessShareLock);
15207
15208 return res;
15209}
15210=====================================================================
15211Found a 49 line (114 tokens) duplication in the following files:
15212Starting at line 1084 of /home/shackle/pggit/postgresql/src/backend/utils/mmgr/aset.c
15213Starting at line 552 of /home/shackle/pggit/postgresql/src/backend/utils/mmgr/generation.c
15214
15215 set->header.name, chunk);
15216#endif
15217
15218 /*
15219 * Chunk sizes are aligned to power of 2 in AllocSetAlloc(). Maybe the
15220 * allocated area already is >= the new size. (In particular, we always
15221 * fall out here if the requested size is a decrease.)
15222 */
15223 if (oldsize >= size)
15224 {
15225#ifdef MEMORY_CONTEXT_CHECKING
15226 Size oldrequest = chunk->requested_size;
15227
15228#ifdef RANDOMIZE_ALLOCATED_MEMORY
15229 /* We can only fill the extra space if we know the prior request */
15230 if (size > oldrequest)
15231 randomize_mem((char *) pointer + oldrequest,
15232 size - oldrequest);
15233#endif
15234
15235 chunk->requested_size = size;
15236
15237 /*
15238 * If this is an increase, mark any newly-available part UNDEFINED.
15239 * Otherwise, mark the obsolete part NOACCESS.
15240 */
15241 if (size > oldrequest)
15242 VALGRIND_MAKE_MEM_UNDEFINED((char *) pointer + oldrequest,
15243 size - oldrequest);
15244 else
15245 VALGRIND_MAKE_MEM_NOACCESS((char *) pointer + size,
15246 oldsize - size);
15247
15248 /* set mark to catch clobber of "unused" space */
15249 if (size < oldsize)
15250 set_sentinel(pointer, size);
15251#else /* !MEMORY_CONTEXT_CHECKING */
15252
15253 /*
15254 * We don't have the information to determine whether we're growing
15255 * the old request or shrinking it, so we conservatively mark the
15256 * entire new allocation DEFINED.
15257 */
15258 VALGRIND_MAKE_MEM_NOACCESS(pointer, oldsize);
15259 VALGRIND_MAKE_MEM_DEFINED(pointer, size);
15260#endif
15261
15262 /* Disallow external access to private part of chunk header. */
15263 VALGRIND_MAKE_MEM_NOACCESS(chunk, ALLOCCHUNK_PRIVATE_LEN);
15264=====================================================================
15265Found a 31 line (114 tokens) duplication in the following files:
15266Starting at line 771 of /home/shackle/pggit/postgresql/src/backend/utils/mmgr/mcxt.c
15267Starting at line 814 of /home/shackle/pggit/postgresql/src/backend/utils/mmgr/mcxt.c
15268Starting at line 852 of /home/shackle/pggit/postgresql/src/backend/utils/mmgr/mcxt.c
15269
15270MemoryContextAlloc(MemoryContext context, Size size)
15271{
15272 void *ret;
15273
15274 AssertArg(MemoryContextIsValid(context));
15275 AssertNotInCriticalSection(context);
15276
15277 if (!AllocSizeIsValid(size))
15278 elog(ERROR, "invalid memory alloc request size %zu", size);
15279
15280 context->isReset = false;
15281
15282 ret = context->methods->alloc(context, size);
15283 if (unlikely(ret == NULL))
15284 {
15285 MemoryContextStats(TopMemoryContext);
15286
15287 /*
15288 * Here, and elsewhere in this module, we show the target context's
15289 * "name" but not its "ident" (if any) in user-visible error messages.
15290 * The "ident" string might contain security-sensitive data, such as
15291 * values in SQL commands.
15292 */
15293 ereport(ERROR,
15294 (errcode(ERRCODE_OUT_OF_MEMORY),
15295 errmsg("out of memory"),
15296 errdetail("Failed on request of size %zu in memory context \"%s\".",
15297 size, context->name)));
15298 }
15299
15300 VALGRIND_MEMPOOL_ALLOC(context, ret, size);
15301=====================================================================
15302Found a 16 line (114 tokens) duplication in the following files:
15303Starting at line 902 of /home/shackle/pggit/postgresql/src/backend/utils/adt/numeric.c
15304Starting at line 555 of /home/shackle/pggit/postgresql/src/backend/utils/adt/varchar.c
15305
15306numeric_transform(PG_FUNCTION_ARGS)
15307{
15308 FuncExpr *expr = castNode(FuncExpr, PG_GETARG_POINTER(0));
15309 Node *ret = NULL;
15310 Node *typmod;
15311
15312 Assert(list_length(expr->args) >= 2);
15313
15314 typmod = (Node *) lsecond(expr->args);
15315
15316 if (IsA(typmod, Const) &&!((Const *) typmod)->constisnull)
15317 {
15318 Node *source = (Node *) linitial(expr->args);
15319 int32 old_typmod = exprTypmod(source);
15320 int32 new_typmod = DatumGetInt32(((Const *) typmod)->constvalue);
15321 int32 old_scale = (old_typmod - VARHDRSZ) & 0xffff;
15322=====================================================================
15323Found a 22 line (114 tokens) duplication in the following files:
15324Starting at line 5361 of /home/shackle/pggit/postgresql/src/backend/access/transam/xact.c
15325Starting at line 5496 of /home/shackle/pggit/postgresql/src/backend/access/transam/xact.c
15326
15327 XLogRegisterData((char *) (&xl_xinfo.xinfo), sizeof(xl_xinfo.xinfo));
15328
15329 if (xl_xinfo.xinfo & XACT_XINFO_HAS_DBINFO)
15330 XLogRegisterData((char *) (&xl_dbinfo), sizeof(xl_dbinfo));
15331
15332 if (xl_xinfo.xinfo & XACT_XINFO_HAS_SUBXACTS)
15333 {
15334 XLogRegisterData((char *) (&xl_subxacts),
15335 MinSizeOfXactSubxacts);
15336 XLogRegisterData((char *) subxacts,
15337 nsubxacts * sizeof(TransactionId));
15338 }
15339
15340 if (xl_xinfo.xinfo & XACT_XINFO_HAS_RELFILENODES)
15341 {
15342 XLogRegisterData((char *) (&xl_relfilenodes),
15343 MinSizeOfXactRelfilenodes);
15344 XLogRegisterData((char *) rels,
15345 nrels * sizeof(RelFileNode));
15346 }
15347
15348 if (xl_xinfo.xinfo & XACT_XINFO_HAS_INVALS)
15349=====================================================================
15350Found a 26 line (114 tokens) duplication in the following files:
15351Starting at line 486 of /home/shackle/pggit/postgresql/src/backend/access/hash/hashfunc.c
15352Starting at line 586 of /home/shackle/pggit/postgresql/src/backend/access/hash/hashfunc.c
15353Starting at line 726 of /home/shackle/pggit/postgresql/src/backend/access/hash/hashfunc.c
15354Starting at line 826 of /home/shackle/pggit/postgresql/src/backend/access/hash/hashfunc.c
15355
15356 break;
15357 case 3:
15358 a += ((uint32) k[2] << 8);
15359 /* fall through */
15360 case 2:
15361 a += ((uint32) k[1] << 16);
15362 /* fall through */
15363 case 1:
15364 a += ((uint32) k[0] << 24);
15365 /* case 0: nothing left to add */
15366 }
15367#else /* !WORDS_BIGENDIAN */
15368 switch (len)
15369 {
15370 case 11:
15371 c += ((uint32) k[10] << 24);
15372 /* fall through */
15373 case 10:
15374 c += ((uint32) k[9] << 16);
15375 /* fall through */
15376 case 9:
15377 c += ((uint32) k[8] << 8);
15378 /* fall through */
15379 case 8:
15380 /* the lowest byte of c is reserved for the length */
15381 b += ka[1];
15382=====================================================================
15383Found a 22 line (113 tokens) duplication in the following files:
15384Starting at line 435 of /home/shackle/pggit/postgresql/contrib/hstore/hstore_gist.c
15385Starting at line 375 of /home/shackle/pggit/postgresql/contrib/ltree/_ltree_gist.c
15386
15387 union_r = GETSIGN(datum_r);
15388
15389 for (k = 0; k < maxoff; k++)
15390 {
15391 j = costvector[k].pos;
15392 if (j == seed_1)
15393 {
15394 *left++ = j;
15395 v->spl_nleft++;
15396 continue;
15397 }
15398 else if (j == seed_2)
15399 {
15400 *right++ = j;
15401 v->spl_nright++;
15402 continue;
15403 }
15404 _j = GETENTRY(entryvec, j);
15405 size_alpha = hemdist(datum_l, _j);
15406 size_beta = hemdist(datum_r, _j);
15407
15408 if (size_alpha < size_beta + WISH_F(v->spl_nleft, v->spl_nright, 0.0001))
15409=====================================================================
15410Found a 21 line (113 tokens) duplication in the following files:
15411Starting at line 261 of /home/shackle/pggit/postgresql/src/bin/pg_test_fsync/pg_test_fsync.c
15412Starting at line 364 of /home/shackle/pggit/postgresql/src/bin/pg_test_fsync/pg_test_fsync.c
15413
15414 if ((tmpfile = open(filename, O_RDWR | O_DSYNC | PG_O_DIRECT, 0)) == -1)
15415 {
15416 printf(NA_FORMAT, _("n/a*"));
15417 fs_warning = true;
15418 }
15419 else
15420 {
15421 START_TIMER;
15422 for (ops = 0; alarm_triggered == false; ops++)
15423 {
15424 for (writes = 0; writes < writes_per_op; writes++)
15425 if (write(tmpfile, buf, XLOG_BLCKSZ) != XLOG_BLCKSZ)
15426 die("write failed");
15427 if (lseek(tmpfile, 0, SEEK_SET) == -1)
15428 die("seek failed");
15429 }
15430 STOP_TIMER;
15431 close(tmpfile);
15432 }
15433#else
15434 printf(NA_FORMAT, _("n/a"));
15435=====================================================================
15436Found a 31 line (113 tokens) duplication in the following files:
15437Starting at line 143 of /home/shackle/pggit/postgresql/src/include/catalog/pg_aggregate.h
15438Starting at line 45 of /home/shackle/pggit/postgresql/src/backend/catalog/pg_aggregate.c
15439
15440extern ObjectAddress AggregateCreate(const char *aggName,
15441 Oid aggNamespace,
15442 char aggKind,
15443 int numArgs,
15444 int numDirectArgs,
15445 oidvector *parameterTypes,
15446 Datum allParameterTypes,
15447 Datum parameterModes,
15448 Datum parameterNames,
15449 List *parameterDefaults,
15450 Oid variadicArgType,
15451 List *aggtransfnName,
15452 List *aggfinalfnName,
15453 List *aggcombinefnName,
15454 List *aggserialfnName,
15455 List *aggdeserialfnName,
15456 List *aggmtransfnName,
15457 List *aggminvtransfnName,
15458 List *aggmfinalfnName,
15459 bool finalfnExtraArgs,
15460 bool mfinalfnExtraArgs,
15461 char finalfnModify,
15462 char mfinalfnModify,
15463 List *aggsortopName,
15464 Oid aggTransType,
15465 int32 aggTransSpace,
15466 Oid aggmTransType,
15467 int32 aggmTransSpace,
15468 const char *agginitval,
15469 const char *aggminitval,
15470 char proparallel);
15471=====================================================================
15472Found a 16 line (113 tokens) duplication in the following files:
15473Starting at line 193 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/thread-thread_implicit.c
15474Starting at line 192 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/thread-thread.c
15475
15476 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test_thread ( thread , iteration ) values ( $1 , $2 )",
15477 ECPGt_char,(l_connection),(long)128,(long)1,(128)*sizeof(char),
15478 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
15479 ECPGt_int,&(l_i),(long)1,(long)1,sizeof(int),
15480 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
15481#line 132 "thread_implicit.pgc"
15482
15483if (sqlca.sqlcode < 0) sqlprint();}
15484#line 132 "thread_implicit.pgc"
15485
15486 if( sqlca.sqlcode != 0 )
15487 printf("%s: ERROR: insert failed!\n", l_connection);
15488 }
15489
15490 /* all done */
15491 { ECPGtrans(__LINE__, NULL, "commit");
15492=====================================================================
15493Found a 38 line (113 tokens) duplication in the following files:
15494Starting at line 36 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/compat_informix-dec_test.c
15495Starting at line 33 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/pgtypeslib-num_test2.c
15496
15497static void
15498print_double(double x)
15499{
15500#ifdef WIN32
15501 /* Change Windows' 3-digit exponents to look like everyone else's */
15502 char convert[128];
15503 int vallen;
15504
15505 sprintf(convert, "%g", x);
15506 vallen = strlen(convert);
15507
15508 if (vallen >= 6 &&
15509 convert[vallen - 5] == 'e' &&
15510 convert[vallen - 3] == '0')
15511 {
15512 convert[vallen - 3] = convert[vallen - 2];
15513 convert[vallen - 2] = convert[vallen - 1];
15514 convert[vallen - 1] = '\0';
15515 }
15516
15517 printf("%s", convert);
15518#else
15519 printf("%g", x);
15520#endif
15521}
15522
15523#line 10 "dec_test.pgc"
15524
15525
15526
15527/*
15528TODO:
15529 deccmp => DECUNKNOWN
15530 decimal point: , and/or . ?
15531 ECPG_INFORMIX_BAD_EXPONENT ?
15532*/
15533
15534char* decs[] = { "2E394", "-2", ".794", "3.44", "592.49E21", "-32.84e4",
15535=====================================================================
15536Found a 28 line (113 tokens) duplication in the following files:
15537Starting at line 213 of /home/shackle/pggit/postgresql/src/backend/utils/mb/wchar.c
15538Starting at line 281 of /home/shackle/pggit/postgresql/src/backend/utils/mb/wchar.c
15539
15540 len -= 3;
15541 }
15542 else if (*from == SS3 && len >= 3) /* code set 3 (unused ?) */
15543 {
15544 from++;
15545 *to = (SS3 << 16) | (*from++ << 8);
15546 *to |= *from++;
15547 len -= 3;
15548 }
15549 else if (IS_HIGHBIT_SET(*from) && len >= 2) /* code set 1 */
15550 {
15551 *to = *from++ << 8;
15552 *to |= *from++;
15553 len -= 2;
15554 }
15555 else
15556 {
15557 *to = *from++;
15558 len--;
15559 }
15560 to++;
15561 cnt++;
15562 }
15563 *to = 0;
15564 return cnt;
15565}
15566
15567static int
15568=====================================================================
15569Found a 18 line (113 tokens) duplication in the following files:
15570Starting at line 4821 of /home/shackle/pggit/postgresql/src/backend/utils/adt/jsonfuncs.c
15571Starting at line 4934 of /home/shackle/pggit/postgresql/src/backend/utils/adt/jsonfuncs.c
15572
15573 r = JsonbIteratorNext(it, &v, false);
15574 (void) pushJsonbValue(st, r, r < WJB_BEGIN_ARRAY ? &v : NULL);
15575 if (r == WJB_BEGIN_ARRAY || r == WJB_BEGIN_OBJECT)
15576 {
15577 int walking_level = 1;
15578
15579 while (walking_level != 0)
15580 {
15581 r = JsonbIteratorNext(it, &v, false);
15582
15583 if (r == WJB_BEGIN_ARRAY || r == WJB_BEGIN_OBJECT)
15584 ++walking_level;
15585 if (r == WJB_END_ARRAY || r == WJB_END_OBJECT)
15586 --walking_level;
15587
15588 (void) pushJsonbValue(st, r, r < WJB_BEGIN_ARRAY ? &v : NULL);
15589 }
15590 }
15591=====================================================================
15592Found a 40 line (113 tokens) duplication in the following files:
15593Starting at line 2163 of /home/shackle/pggit/postgresql/src/backend/utils/adt/float.c
15594Starting at line 2282 of /home/shackle/pggit/postgresql/src/backend/utils/adt/float.c
15595
15596 volatile float8 cot_arg1;
15597 int sign = 1;
15598
15599 /*
15600 * Per the POSIX spec, return NaN if the input is NaN and throw an error
15601 * if the input is infinite.
15602 */
15603 if (isnan(arg1))
15604 PG_RETURN_FLOAT8(get_float8_nan());
15605
15606 if (isinf(arg1))
15607 ereport(ERROR,
15608 (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
15609 errmsg("input is out of range")));
15610
15611 INIT_DEGREE_CONSTANTS();
15612
15613 /* Reduce the range of the input to [0,90] degrees */
15614 arg1 = fmod(arg1, 360.0);
15615
15616 if (arg1 < 0.0)
15617 {
15618 /* cotd(-x) = -cotd(x) */
15619 arg1 = -arg1;
15620 sign = -sign;
15621 }
15622
15623 if (arg1 > 180.0)
15624 {
15625 /* cotd(360-x) = -cotd(x) */
15626 arg1 = 360.0 - arg1;
15627 sign = -sign;
15628 }
15629
15630 if (arg1 > 90.0)
15631 {
15632 /* cotd(180-x) = -cotd(x) */
15633 arg1 = 180.0 - arg1;
15634 sign = -sign;
15635 }
15636=====================================================================
15637Found a 26 line (113 tokens) duplication in the following files:
15638Starting at line 747 of /home/shackle/pggit/postgresql/src/backend/jit/llvm/llvmjit_expr.c
15639Starting at line 848 of /home/shackle/pggit/postgresql/src/backend/jit/llvm/llvmjit_expr.c
15640
15641 LLVMPositionBuilderAtEnd(b, b_boolisfalse);
15642 /* result is already set to FALSE, need not change it */
15643 /* and jump to the end of the AND expression */
15644 LLVMBuildBr(b, opblocks[op->d.boolexpr.jumpdone]);
15645
15646 /* Build block that continues if bool is TRUE. */
15647 LLVMPositionBuilderAtEnd(b, b_boolcont);
15648
15649 v_boolanynull = LLVMBuildLoad(b, v_boolanynullp, "");
15650
15651 /* set value to NULL if any previous values were NULL */
15652 LLVMBuildCondBr(b,
15653 LLVMBuildICmp(b, LLVMIntEQ, v_boolanynull,
15654 l_sbool_const(0), ""),
15655 opblocks[i + 1], b_boolisanynull);
15656
15657 LLVMPositionBuilderAtEnd(b, b_boolisanynull);
15658 /* set resnull to true */
15659 LLVMBuildStore(b, l_sbool_const(1), v_resnullp);
15660 /* reset resvalue */
15661 LLVMBuildStore(b, l_sizet_const(0), v_resvaluep);
15662
15663 LLVMBuildBr(b, opblocks[i + 1]);
15664 break;
15665 }
15666 case EEOP_BOOL_OR_STEP_FIRST:
15667=====================================================================
15668Found a 25 line (112 tokens) duplication in the following files:
15669Starting at line 126 of /home/shackle/pggit/postgresql/src/test/examples/testlo64.c
15670Starting at line 120 of /home/shackle/pggit/postgresql/src/test/examples/testlo.c
15671
15672 fprintf(stderr, "error in lo_lseek64: %s", PQerrorMessage(conn));
15673
15674 buf = malloc(len + 1);
15675
15676 for (i = 0; i < len; i++)
15677 buf[i] = 'X';
15678 buf[i] = '\0';
15679
15680 nwritten = 0;
15681 while (len - nwritten > 0)
15682 {
15683 nbytes = lo_write(conn, lobj_fd, buf + nwritten, len - nwritten);
15684 nwritten += nbytes;
15685 if (nbytes <= 0)
15686 {
15687 fprintf(stderr, "\nWRITE FAILED!\n");
15688 break;
15689 }
15690 }
15691 free(buf);
15692 fprintf(stderr, "\n");
15693 lo_close(conn, lobj_fd);
15694}
15695
15696static void
15697=====================================================================
15698Found a 24 line (112 tokens) duplication in the following files:
15699Starting at line 1994 of /home/shackle/pggit/postgresql/src/backend/optimizer/plan/setrefs.c
15700Starting at line 2044 of /home/shackle/pggit/postgresql/src/backend/optimizer/plan/setrefs.c
15701
15702build_tlist_index(List *tlist)
15703{
15704 indexed_tlist *itlist;
15705 tlist_vinfo *vinfo;
15706 ListCell *l;
15707
15708 /* Create data structure with enough slots for all tlist entries */
15709 itlist = (indexed_tlist *)
15710 palloc(offsetof(indexed_tlist, vars) +
15711 list_length(tlist) * sizeof(tlist_vinfo));
15712
15713 itlist->tlist = tlist;
15714 itlist->has_ph_vars = false;
15715 itlist->has_non_vars = false;
15716
15717 /* Find the Vars and fill in the index array */
15718 vinfo = itlist->vars;
15719 foreach(l, tlist)
15720 {
15721 TargetEntry *tle = (TargetEntry *) lfirst(l);
15722
15723 if (tle->expr && IsA(tle->expr, Var))
15724 {
15725 Var *var = (Var *) tle->expr;
15726=====================================================================
15727Found a 22 line (112 tokens) duplication in the following files:
15728Starting at line 336 of /home/shackle/pggit/postgresql/src/backend/storage/buffer/localbuf.c
15729Starting at line 380 of /home/shackle/pggit/postgresql/src/backend/storage/buffer/localbuf.c
15730
15731 bufHdr->tag.blockNum >= firstDelBlock)
15732 {
15733 if (LocalRefCount[i] != 0)
15734 elog(ERROR, "block %u of %s is still referenced (local %u)",
15735 bufHdr->tag.blockNum,
15736 relpathbackend(bufHdr->tag.rnode, MyBackendId,
15737 bufHdr->tag.forkNum),
15738 LocalRefCount[i]);
15739 /* Remove entry from hashtable */
15740 hresult = (LocalBufferLookupEnt *)
15741 hash_search(LocalBufHash, (void *) &bufHdr->tag,
15742 HASH_REMOVE, NULL);
15743 if (!hresult) /* shouldn't happen */
15744 elog(ERROR, "local buffer hash table corrupted");
15745 /* Mark buffer invalid */
15746 CLEAR_BUFFERTAG(bufHdr->tag);
15747 buf_state &= ~BUF_FLAG_MASK;
15748 buf_state &= ~BUF_USAGECOUNT_MASK;
15749 pg_atomic_unlocked_write_u32(&bufHdr->state, buf_state);
15750 }
15751 }
15752}
15753=====================================================================
15754Found a 27 line (112 tokens) duplication in the following files:
15755Starting at line 240 of /home/shackle/pggit/postgresql/src/backend/executor/nodeWindowAgg.c
15756Starting at line 417 of /home/shackle/pggit/postgresql/src/backend/executor/nodeWindowAgg.c
15757
15758advance_windowaggregate(WindowAggState *winstate,
15759 WindowStatePerFunc perfuncstate,
15760 WindowStatePerAgg peraggstate)
15761{
15762 WindowFuncExprState *wfuncstate = perfuncstate->wfuncstate;
15763 int numArguments = perfuncstate->numArguments;
15764 FunctionCallInfoData fcinfodata;
15765 FunctionCallInfo fcinfo = &fcinfodata;
15766 Datum newVal;
15767 ListCell *arg;
15768 int i;
15769 MemoryContext oldContext;
15770 ExprContext *econtext = winstate->tmpcontext;
15771 ExprState *filter = wfuncstate->aggfilter;
15772
15773 oldContext = MemoryContextSwitchTo(econtext->ecxt_per_tuple_memory);
15774
15775 /* Skip anything FILTERed out */
15776 if (filter)
15777 {
15778 bool isnull;
15779 Datum res = ExecEvalExpr(filter, econtext, &isnull);
15780
15781 if (isnull || !DatumGetBool(res))
15782 {
15783 MemoryContextSwitchTo(oldContext);
15784 return;
15785=====================================================================
15786Found a 5 line (112 tokens) duplication in the following files:
15787Starting at line 98 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
15788Starting at line 103 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
15789
15790 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
15791 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
15792 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
15793 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
15794 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
15795=====================================================================
15796Found a 12 line (112 tokens) duplication in the following files:
15797Starting at line 303 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c
15798Starting at line 538 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c
15799
15800 c2 = mic[2];
15801 k = (c1 << 8) | (c2 & 0xff);
15802 if (k >= 0xf5a1)
15803 {
15804 /* UDC1 */
15805 c1 -= 0x54;
15806 *p++ = ((c1 - 0xa1) >> 1) + ((c1 < 0xdf) ? 0x81 : 0xc1) + 0x6f;
15807 }
15808 else
15809 *p++ = ((c1 - 0xa1) >> 1) + ((c1 < 0xdf) ? 0x81 : 0xc1);
15810 *p++ = c2 - ((c1 & 1) ? ((c2 < 0xe0) ? 0x61 : 0x60) : 2);
15811 }
15812=====================================================================
15813Found a 28 line (112 tokens) duplication in the following files:
15814Starting at line 86 of /home/shackle/pggit/postgresql/src/backend/utils/mb/wchar.c
15815Starting at line 213 of /home/shackle/pggit/postgresql/src/backend/utils/mb/wchar.c
15816Starting at line 281 of /home/shackle/pggit/postgresql/src/backend/utils/mb/wchar.c
15817
15818 len -= 2;
15819 }
15820 else if (*from == SS3 && len >= 3) /* JIS X 0212 KANJI */
15821 {
15822 from++;
15823 *to = (SS3 << 16) | (*from++ << 8);
15824 *to |= *from++;
15825 len -= 3;
15826 }
15827 else if (IS_HIGHBIT_SET(*from) && len >= 2) /* JIS X 0208 KANJI */
15828 {
15829 *to = *from++ << 8;
15830 *to |= *from++;
15831 len -= 2;
15832 }
15833 else /* must be ASCII */
15834 {
15835 *to = *from++;
15836 len--;
15837 }
15838 to++;
15839 cnt++;
15840 }
15841 *to = 0;
15842 return cnt;
15843}
15844
15845static inline int
15846=====================================================================
15847Found a 38 line (111 tokens) duplication in the following files:
15848Starting at line 972 of /home/shackle/pggit/postgresql/contrib/postgres_fdw/postgres_fdw.c
15849Starting at line 1048 of /home/shackle/pggit/postgresql/contrib/postgres_fdw/postgres_fdw.c
15850
15851 foreach(lc, baserel->joininfo)
15852 {
15853 RestrictInfo *rinfo = (RestrictInfo *) lfirst(lc);
15854 Relids required_outer;
15855 ParamPathInfo *param_info;
15856
15857 /* Check if clause can be moved to this rel */
15858 if (!join_clause_is_movable_to(rinfo, baserel))
15859 continue;
15860
15861 /* See if it is safe to send to remote */
15862 if (!is_foreign_expr(root, baserel, rinfo->clause))
15863 continue;
15864
15865 /* Calculate required outer rels for the resulting path */
15866 required_outer = bms_union(rinfo->clause_relids,
15867 baserel->lateral_relids);
15868 /* We do not want the foreign rel itself listed in required_outer */
15869 required_outer = bms_del_member(required_outer, baserel->relid);
15870
15871 /*
15872 * required_outer probably can't be empty here, but if it were, we
15873 * couldn't make a parameterized path.
15874 */
15875 if (bms_is_empty(required_outer))
15876 continue;
15877
15878 /* Get the ParamPathInfo */
15879 param_info = get_baserel_parampathinfo(root, baserel,
15880 required_outer);
15881 Assert(param_info != NULL);
15882
15883 /*
15884 * Add it to list unless we already have it. Testing pointer equality
15885 * is OK since get_baserel_parampathinfo won't make duplicates.
15886 */
15887 ppi_list = list_append_unique_ptr(ppi_list, param_info);
15888 }
15889=====================================================================
15890Found a 34 line (111 tokens) duplication in the following files:
15891Starting at line 5419 of /home/shackle/pggit/postgresql/src/pl/plpgsql/src/pl_exec.c
15892Starting at line 6513 of /home/shackle/pggit/postgresql/src/pl/plpgsql/src/pl_exec.c
15893
15894 ExpandedRecordHeader *erh;
15895
15896 rec = (PLpgSQL_rec *) (estate->datums[recfield->recparentno]);
15897 erh = rec->erh;
15898
15899 /*
15900 * If record variable is NULL, instantiate it if it has a
15901 * named composite type, else complain. (This won't change
15902 * the logical state of the record: it's still NULL.)
15903 */
15904 if (erh == NULL)
15905 {
15906 instantiate_empty_record_variable(estate, rec);
15907 erh = rec->erh;
15908 }
15909
15910 /*
15911 * Look up the field's properties if we have not already, or
15912 * if the tuple descriptor ID changed since last time.
15913 */
15914 if (unlikely(recfield->rectupledescid != erh->er_tupdesc_id))
15915 {
15916 if (!expanded_record_lookup_field(erh,
15917 recfield->fieldname,
15918 &recfield->finfo))
15919 ereport(ERROR,
15920 (errcode(ERRCODE_UNDEFINED_COLUMN),
15921 errmsg("record \"%s\" has no field \"%s\"",
15922 rec->refname, recfield->fieldname)));
15923 recfield->rectupledescid = erh->er_tupdesc_id;
15924 }
15925
15926 /* Report type data. */
15927 *typeid = recfield->finfo.ftypeid;
15928=====================================================================
15929Found a 3 line (111 tokens) duplication in the following files:
15930Starting at line 31 of /home/shackle/pggit/postgresql/src/common/base64.c
15931Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
15932Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
15933Starting at line 207 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
15934Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
15935
15936 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
15937 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
15938 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
15939=====================================================================
15940Found a 3 line (111 tokens) duplication in the following files:
15941Starting at line 31 of /home/shackle/pggit/postgresql/src/common/base64.c
15942Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
15943Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
15944Starting at line 207 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
15945Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
15946
15947 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
15948 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
15949 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
15950=====================================================================
15951Found a 25 line (111 tokens) duplication in the following files:
15952Starting at line 32 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/pgtypeslib-num_test.c
15953Starting at line 36 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/compat_informix-dec_test.c
15954Starting at line 33 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/pgtypeslib-num_test2.c
15955Starting at line 5 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/printf_hack.h
15956
15957static void
15958print_double(double x)
15959{
15960#ifdef WIN32
15961 /* Change Windows' 3-digit exponents to look like everyone else's */
15962 char convert[128];
15963 int vallen;
15964
15965 sprintf(convert, "%g", x);
15966 vallen = strlen(convert);
15967
15968 if (vallen >= 6 &&
15969 convert[vallen - 5] == 'e' &&
15970 convert[vallen - 3] == '0')
15971 {
15972 convert[vallen - 3] = convert[vallen - 2];
15973 convert[vallen - 2] = convert[vallen - 1];
15974 convert[vallen - 1] = '\0';
15975 }
15976
15977 printf("%s", convert);
15978#else
15979 printf("%g", x);
15980#endif
15981}
15982=====================================================================
15983Found a 14 line (111 tokens) duplication in the following files:
15984Starting at line 201 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
15985Starting at line 341 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
15986Starting at line 694 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
15987Starting at line 709 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
15988Starting at line 727 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
15989Starting at line 752 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
15990Starting at line 770 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
15991
15992 ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
15993 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
15994 ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
15995 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
15996 ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
15997 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
15998#line 70 "cursor.pgc"
15999
16000if (sqlca.sqlcode < 0) exit (1);}
16001#line 70 "cursor.pgc"
16002
16003 printf("%d %s\n", id, t);
16004
16005 strcpy(msg, "fetch");
16006=====================================================================
16007Found a 14 line (111 tokens) duplication in the following files:
16008Starting at line 216 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
16009Starting at line 231 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
16010Starting at line 249 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
16011Starting at line 274 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
16012Starting at line 292 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
16013Starting at line 356 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
16014Starting at line 371 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
16015Starting at line 389 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
16016Starting at line 418 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
16017Starting at line 436 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
16018Starting at line 509 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
16019Starting at line 524 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
16020Starting at line 539 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
16021Starting at line 557 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
16022Starting at line 582 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
16023Starting at line 600 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
16024Starting at line 679 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
16025
16026 ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
16027 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
16028 ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
16029 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
16030 ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
16031 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
16032#line 74 "cursor.pgc"
16033
16034if (sqlca.sqlcode < 0) exit (1);}
16035#line 74 "cursor.pgc"
16036
16037 printf("%d %s\n", id, t);
16038
16039 strcpy(msg, "fetch 1 from");
16040=====================================================================
16041Found a 36 line (111 tokens) duplication in the following files:
16042Starting at line 482 of /home/shackle/pggit/postgresql/src/backend/utils/adt/int8.c
16043Starting at line 650 of /home/shackle/pggit/postgresql/src/backend/utils/adt/int.c
16044
16045 int64 base = PG_GETARG_INT64(1);
16046 int64 offset = PG_GETARG_INT64(2);
16047 bool sub = PG_GETARG_BOOL(3);
16048 bool less = PG_GETARG_BOOL(4);
16049 int64 sum;
16050
16051 if (offset < 0)
16052 ereport(ERROR,
16053 (errcode(ERRCODE_INVALID_PRECEDING_OR_FOLLOWING_SIZE),
16054 errmsg("invalid preceding or following size in window function")));
16055
16056 if (sub)
16057 offset = -offset; /* cannot overflow */
16058
16059 if (unlikely(pg_add_s64_overflow(base, offset, &sum)))
16060 {
16061 /*
16062 * If sub is false, the true sum is surely more than val, so correct
16063 * answer is the same as "less". If sub is true, the true sum is
16064 * surely less than val, so the answer is "!less".
16065 */
16066 PG_RETURN_BOOL(sub ? !less : less);
16067 }
16068
16069 if (less)
16070 PG_RETURN_BOOL(val <= sum);
16071 else
16072 PG_RETURN_BOOL(val >= sum);
16073}
16074
16075
16076/*----------------------------------------------------------
16077 * Arithmetic operators on 64-bit integers.
16078 *---------------------------------------------------------*/
16079
16080Datum
16081=====================================================================
16082Found a 22 line (111 tokens) duplication in the following files:
16083Starting at line 558 of /home/shackle/pggit/postgresql/src/backend/utils/adt/jsonfuncs.c
16084Starting at line 622 of /home/shackle/pggit/postgresql/src/backend/utils/adt/jsonfuncs.c
16085
16086 MemoryContextSwitchTo(oldcontext);
16087 funcctx->user_fctx = (void *) state;
16088 }
16089
16090 funcctx = SRF_PERCALL_SETUP();
16091 state = (OkeysState *) funcctx->user_fctx;
16092
16093 if (state->sent_count < state->result_count)
16094 {
16095 char *nxt = state->result[state->sent_count++];
16096
16097 SRF_RETURN_NEXT(funcctx, CStringGetTextDatum(nxt));
16098 }
16099
16100 /* cleanup to reduce or eliminate memory leaks */
16101 for (i = 0; i < state->result_count; i++)
16102 pfree(state->result[i]);
16103 pfree(state->result);
16104 pfree(state);
16105
16106 SRF_RETURN_DONE(funcctx);
16107}
16108=====================================================================
16109Found a 18 line (111 tokens) duplication in the following files:
16110Starting at line 1185 of /home/shackle/pggit/postgresql/src/backend/utils/adt/date.c
16111Starting at line 1976 of /home/shackle/pggit/postgresql/src/backend/utils/adt/date.c
16112
16113 TimeADT result;
16114 fsec_t fsec;
16115 struct pg_tm tt,
16116 *tm = &tt;
16117 int tz;
16118 int nf;
16119 int dterr;
16120 char workbuf[MAXDATELEN + 1];
16121 char *field[MAXDATEFIELDS];
16122 int dtype;
16123 int ftype[MAXDATEFIELDS];
16124
16125 dterr = ParseDateTime(str, workbuf, sizeof(workbuf),
16126 field, ftype, MAXDATEFIELDS, &nf);
16127 if (dterr == 0)
16128 dterr = DecodeTimeOnly(field, ftype, nf, &dtype, tm, &fsec, &tz);
16129 if (dterr != 0)
16130 DateTimeParseError(dterr, str, "time");
16131=====================================================================
16132Found a 18 line (111 tokens) duplication in the following files:
16133Starting at line 151 of /home/shackle/pggit/postgresql/src/backend/utils/adt/timestamp.c
16134Starting at line 391 of /home/shackle/pggit/postgresql/src/backend/utils/adt/timestamp.c
16135
16136 Timestamp result;
16137 fsec_t fsec;
16138 struct pg_tm tt,
16139 *tm = &tt;
16140 int tz;
16141 int dtype;
16142 int nf;
16143 int dterr;
16144 char *field[MAXDATEFIELDS];
16145 int ftype[MAXDATEFIELDS];
16146 char workbuf[MAXDATELEN + MAXDATEFIELDS];
16147
16148 dterr = ParseDateTime(str, workbuf, sizeof(workbuf),
16149 field, ftype, MAXDATEFIELDS, &nf);
16150 if (dterr == 0)
16151 dterr = DecodeDateTime(field, ftype, nf, &dtype, tm, &fsec, &tz);
16152 if (dterr != 0)
16153 DateTimeParseError(dterr, str, "timestamp");
16154=====================================================================
16155Found a 21 line (111 tokens) duplication in the following files:
16156Starting at line 3399 of /home/shackle/pggit/postgresql/src/backend/utils/adt/timestamp.c
16157Starting at line 3483 of /home/shackle/pggit/postgresql/src/backend/utils/adt/timestamp.c
16158
16159interval_accum(PG_FUNCTION_ARGS)
16160{
16161 ArrayType *transarray = PG_GETARG_ARRAYTYPE_P(0);
16162 Interval *newval = PG_GETARG_INTERVAL_P(1);
16163 Datum *transdatums;
16164 int ndatums;
16165 Interval sumX,
16166 N;
16167 Interval *newsum;
16168 ArrayType *result;
16169
16170 deconstruct_array(transarray,
16171 INTERVALOID, sizeof(Interval), false, 'd',
16172 &transdatums, NULL, &ndatums);
16173 if (ndatums != 2)
16174 elog(ERROR, "expected 2-element interval array");
16175
16176 sumX = *(DatumGetIntervalP(transdatums[0]));
16177 N = *(DatumGetIntervalP(transdatums[1]));
16178
16179 newsum = DatumGetIntervalP(DirectFunctionCall2(interval_pl,
16180=====================================================================
16181Found a 31 line (111 tokens) duplication in the following files:
16182Starting at line 603 of /home/shackle/pggit/postgresql/src/backend/utils/adt/int.c
16183Starting at line 685 of /home/shackle/pggit/postgresql/src/backend/utils/adt/int.c
16184
16185 int32 base = PG_GETARG_INT32(1);
16186 int32 offset = PG_GETARG_INT32(2);
16187 bool sub = PG_GETARG_BOOL(3);
16188 bool less = PG_GETARG_BOOL(4);
16189 int32 sum;
16190
16191 if (offset < 0)
16192 ereport(ERROR,
16193 (errcode(ERRCODE_INVALID_PRECEDING_OR_FOLLOWING_SIZE),
16194 errmsg("invalid preceding or following size in window function")));
16195
16196 if (sub)
16197 offset = -offset; /* cannot overflow */
16198
16199 if (unlikely(pg_add_s32_overflow(base, offset, &sum)))
16200 {
16201 /*
16202 * If sub is false, the true sum is surely more than val, so correct
16203 * answer is the same as "less". If sub is true, the true sum is
16204 * surely less than val, so the answer is "!less".
16205 */
16206 PG_RETURN_BOOL(sub ? !less : less);
16207 }
16208
16209 if (less)
16210 PG_RETURN_BOOL(val <= sum);
16211 else
16212 PG_RETURN_BOOL(val >= sum);
16213}
16214
16215Datum
16216=====================================================================
16217Found a 34 line (111 tokens) duplication in the following files:
16218Starting at line 145 of /home/shackle/pggit/postgresql/src/backend/access/common/tupconvert.c
16219Starting at line 348 of /home/shackle/pggit/postgresql/src/backend/access/common/tupconvert.c
16220
16221 for (i = 0; i < n; i++)
16222 {
16223 Form_pg_attribute inatt;
16224 Form_pg_attribute outatt;
16225
16226 if (attrMap[i] == (i + 1))
16227 continue;
16228
16229 /*
16230 * If it's a dropped column and the corresponding input column is
16231 * also dropped, we needn't convert. However, attlen and attalign
16232 * must agree.
16233 */
16234 inatt = TupleDescAttr(indesc, i);
16235 outatt = TupleDescAttr(outdesc, i);
16236 if (attrMap[i] == 0 &&
16237 inatt->attisdropped &&
16238 inatt->attlen == outatt->attlen &&
16239 inatt->attalign == outatt->attalign)
16240 continue;
16241
16242 same = false;
16243 break;
16244 }
16245 }
16246 else
16247 same = false;
16248
16249 if (same)
16250 {
16251 /* Runtime conversion is not needed */
16252 pfree(attrMap);
16253 return NULL;
16254 }
16255=====================================================================
16256Found a 30 line (110 tokens) duplication in the following files:
16257Starting at line 59 of /home/shackle/pggit/postgresql/src/bin/scripts/dropuser.c
16258Starting at line 60 of /home/shackle/pggit/postgresql/src/bin/scripts/dropdb.c
16259
16260 handle_help_version_opts(argc, argv, "dropuser", help);
16261
16262 while ((c = getopt_long(argc, argv, "h:p:U:wWei", long_options, &optindex)) != -1)
16263 {
16264 switch (c)
16265 {
16266 case 'h':
16267 host = pg_strdup(optarg);
16268 break;
16269 case 'p':
16270 port = pg_strdup(optarg);
16271 break;
16272 case 'U':
16273 username = pg_strdup(optarg);
16274 break;
16275 case 'w':
16276 prompt_password = TRI_NO;
16277 break;
16278 case 'W':
16279 prompt_password = TRI_YES;
16280 break;
16281 case 'e':
16282 echo = true;
16283 break;
16284 case 'i':
16285 interactive = true;
16286 break;
16287 case 0:
16288 /* this covers the long options */
16289 break;
16290=====================================================================
16291Found a 32 line (110 tokens) duplication in the following files:
16292Starting at line 5053 of /home/shackle/pggit/postgresql/src/pl/plpgsql/src/pl_exec.c
16293Starting at line 6513 of /home/shackle/pggit/postgresql/src/pl/plpgsql/src/pl_exec.c
16294
16295 ExpandedRecordHeader *erh;
16296
16297 rec = (PLpgSQL_rec *) (estate->datums[recfield->recparentno]);
16298 erh = rec->erh;
16299
16300 /*
16301 * If record variable is NULL, instantiate it if it has a
16302 * named composite type, else complain. (This won't change
16303 * the logical state of the record, but if we successfully
16304 * assign below, the unassigned fields will all become NULLs.)
16305 */
16306 if (erh == NULL)
16307 {
16308 instantiate_empty_record_variable(estate, rec);
16309 erh = rec->erh;
16310 }
16311
16312 /*
16313 * Look up the field's properties if we have not already, or
16314 * if the tuple descriptor ID changed since last time.
16315 */
16316 if (unlikely(recfield->rectupledescid != erh->er_tupdesc_id))
16317 {
16318 if (!expanded_record_lookup_field(erh,
16319 recfield->fieldname,
16320 &recfield->finfo))
16321 ereport(ERROR,
16322 (errcode(ERRCODE_UNDEFINED_COLUMN),
16323 errmsg("record \"%s\" has no field \"%s\"",
16324 rec->refname, recfield->fieldname)));
16325 recfield->rectupledescid = erh->er_tupdesc_id;
16326 }
16327=====================================================================
16328Found a 17 line (110 tokens) duplication in the following files:
16329Starting at line 377 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c
16330Starting at line 438 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c
16331
16332 inp_sqlda = (sqlda_t *)malloc(sizeof(sqlda_t));
16333 memset(inp_sqlda, 0, sizeof(sqlda_t));
16334 inp_sqlda->sqld = 1;
16335 inp_sqlda->sqlvar = malloc(sizeof(sqlvar_t));
16336 memset(inp_sqlda->sqlvar, 0, sizeof(sqlvar_t));
16337
16338 inp_sqlda->sqlvar[0].sqltype = SQLINT;
16339 inp_sqlda->sqlvar[0].sqldata = (char *)&id;
16340
16341 printf("EXECUTE RECORD 4\n");
16342
16343 id = 4;
16344
16345 outp_sqlda = NULL;
16346
16347 strcpy(msg, "prepare");
16348 { ECPGprepare(__LINE__, NULL, 0, "st_id3", stmt2);
16349=====================================================================
16350Found a 28 line (110 tokens) duplication in the following files:
16351Starting at line 1499 of /home/shackle/pggit/postgresql/src/backend/regex/regc_nfa.c
16352Starting at line 1666 of /home/shackle/pggit/postgresql/src/backend/regex/regc_nfa.c
16353
16354 if (pull(nfa, a, &intermediates))
16355 progress = 1;
16356 }
16357 /* clear tmp fields of intermediate states created here */
16358 while (intermediates != NULL)
16359 {
16360 struct state *ns = intermediates->tmp;
16361
16362 intermediates->tmp = NULL;
16363 intermediates = ns;
16364 }
16365 /* if s is now useless, get rid of it */
16366 if ((s->nins == 0 || s->nouts == 0) && !s->flag)
16367 dropstate(nfa, s);
16368 }
16369 if (progress && f != NULL)
16370 dumpnfa(nfa, f);
16371 } while (progress && !NISERR());
16372 if (NISERR())
16373 return;
16374
16375 /*
16376 * Any ^ constraints we were able to pull to the start state can now be
16377 * replaced by PLAIN arcs referencing the BOS or BOL colors. There should
16378 * be no other ^ or BEHIND arcs left in the NFA, though we do not check
16379 * that here (compact() will fail if so).
16380 */
16381 for (a = nfa->pre->outs; a != NULL; a = nexta)
16382=====================================================================
16383Found a 25 line (110 tokens) duplication in the following files:
16384Starting at line 223 of /home/shackle/pggit/postgresql/src/backend/executor/nodeGatherMerge.c
16385Starting at line 179 of /home/shackle/pggit/postgresql/src/backend/executor/nodeGather.c
16386
16387 gm->initParam);
16388
16389 /* Try to launch workers. */
16390 pcxt = node->pei->pcxt;
16391 LaunchParallelWorkers(pcxt);
16392 /* We save # workers launched for the benefit of EXPLAIN */
16393 node->nworkers_launched = pcxt->nworkers_launched;
16394
16395 /* Set up tuple queue readers to read the results. */
16396 if (pcxt->nworkers_launched > 0)
16397 {
16398 ExecParallelCreateReaders(node->pei);
16399 /* Make a working array showing the active readers */
16400 node->nreaders = pcxt->nworkers_launched;
16401 node->reader = (TupleQueueReader **)
16402 palloc(node->nreaders * sizeof(TupleQueueReader *));
16403 memcpy(node->reader, node->pei->reader,
16404 node->nreaders * sizeof(TupleQueueReader *));
16405 }
16406 else
16407 {
16408 /* No workers? Then never mind. */
16409 node->nreaders = 0;
16410 node->reader = NULL;
16411 }
16412=====================================================================
16413Found a 28 line (110 tokens) duplication in the following files:
16414Starting at line 1414 of /home/shackle/pggit/postgresql/src/backend/executor/nodeIndexscan.c
16415Starting at line 1533 of /home/shackle/pggit/postgresql/src/backend/executor/nodeIndexscan.c
16416
16417 Assert(rightop != NULL);
16418
16419 if (IsA(rightop, Const))
16420 {
16421 /* OK, simple constant comparison value */
16422 scanvalue = ((Const *) rightop)->constvalue;
16423 if (((Const *) rightop)->constisnull)
16424 flags |= SK_ISNULL;
16425 }
16426 else
16427 {
16428 /* Need to treat this one as a runtime key */
16429 if (n_runtime_keys >= max_runtime_keys)
16430 {
16431 if (max_runtime_keys == 0)
16432 {
16433 max_runtime_keys = 8;
16434 runtime_keys = (IndexRuntimeKeyInfo *)
16435 palloc(max_runtime_keys * sizeof(IndexRuntimeKeyInfo));
16436 }
16437 else
16438 {
16439 max_runtime_keys *= 2;
16440 runtime_keys = (IndexRuntimeKeyInfo *)
16441 repalloc(runtime_keys, max_runtime_keys * sizeof(IndexRuntimeKeyInfo));
16442 }
16443 }
16444 runtime_keys[n_runtime_keys].scan_key = this_sub_key;
16445=====================================================================
16446Found a 5 line (110 tokens) duplication in the following files:
16447Starting at line 98 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
16448Starting at line 103 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
16449
16450 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
16451 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
16452 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
16453 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
16454 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
16455=====================================================================
16456Found a 25 line (110 tokens) duplication in the following files:
16457Starting at line 472 of /home/shackle/pggit/postgresql/src/backend/utils/adt/genfile.c
16458Starting at line 550 of /home/shackle/pggit/postgresql/src/backend/utils/adt/genfile.c
16459
16460 fctx->include_dot_dirs = include_dot_dirs;
16461 fctx->dirdesc = AllocateDir(fctx->location);
16462
16463 if (!fctx->dirdesc)
16464 {
16465 if (missing_ok && errno == ENOENT)
16466 {
16467 MemoryContextSwitchTo(oldcontext);
16468 SRF_RETURN_DONE(funcctx);
16469 }
16470 else
16471 ereport(ERROR,
16472 (errcode_for_file_access(),
16473 errmsg("could not open directory \"%s\": %m",
16474 fctx->location)));
16475 }
16476 funcctx->user_fctx = fctx;
16477 MemoryContextSwitchTo(oldcontext);
16478 }
16479
16480 funcctx = SRF_PERCALL_SETUP();
16481 fctx = (directory_fctx *) funcctx->user_fctx;
16482
16483 while ((de = ReadDir(fctx->dirdesc, fctx->location)) != NULL)
16484 {
16485=====================================================================
16486Found a 35 line (110 tokens) duplication in the following files:
16487Starting at line 72 of /home/shackle/pggit/postgresql/src/backend/replication/walreceiverfuncs.c
16488Starting at line 117 of /home/shackle/pggit/postgresql/src/backend/replication/walreceiverfuncs.c
16489
16490WalRcvRunning(void)
16491{
16492 WalRcvData *walrcv = WalRcv;
16493 WalRcvState state;
16494 pg_time_t startTime;
16495
16496 SpinLockAcquire(&walrcv->mutex);
16497
16498 state = walrcv->walRcvState;
16499 startTime = walrcv->startTime;
16500
16501 SpinLockRelease(&walrcv->mutex);
16502
16503 /*
16504 * If it has taken too long for walreceiver to start up, give up. Setting
16505 * the state to STOPPED ensures that if walreceiver later does start up
16506 * after all, it will see that it's not supposed to be running and die
16507 * without doing anything.
16508 */
16509 if (state == WALRCV_STARTING)
16510 {
16511 pg_time_t now = (pg_time_t) time(NULL);
16512
16513 if ((now - startTime) > WALRCV_STARTUP_TIMEOUT)
16514 {
16515 SpinLockAcquire(&walrcv->mutex);
16516
16517 if (walrcv->walRcvState == WALRCV_STARTING)
16518 state = walrcv->walRcvState = WALRCV_STOPPED;
16519
16520 SpinLockRelease(&walrcv->mutex);
16521 }
16522 }
16523
16524 if (state != WALRCV_STOPPED)
16525=====================================================================
16526Found a 13 line (109 tokens) duplication in the following files:
16527Starting at line 6214 of /home/shackle/pggit/postgresql/src/pl/plperl/ppport.h
16528Starting at line 6234 of /home/shackle/pggit/postgresql/src/pl/plperl/ppport.h
16529
16530 int digit = *s - '0';
16531 if (digit >= 0 && digit <= 9) {
16532 value = value * 10 + digit;
16533 if (++s < send) {
16534 digit = *s - '0';
16535 if (digit >= 0 && digit <= 9) {
16536 value = value * 10 + digit;
16537 if (++s < send) {
16538 digit = *s - '0';
16539 if (digit >= 0 && digit <= 9) {
16540 value = value * 10 + digit;
16541 if (++s < send) {
16542 digit = *s - '0';
16543=====================================================================
16544Found a 3 line (109 tokens) duplication in the following files:
16545Starting at line 3566 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
16546Starting at line 120 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
16547Starting at line 46 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
16548
16549 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1,
16550 -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
16551 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
16552=====================================================================
16553Found a 3 line (109 tokens) duplication in the following files:
16554Starting at line 3568 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
16555Starting at line 118 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
16556Starting at line 44 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
16557
16558 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
16559 -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
16560 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
16561=====================================================================
16562Found a 19 line (109 tokens) duplication in the following files:
16563Starting at line 1073 of /home/shackle/pggit/postgresql/src/backend/optimizer/prep/prepjointree.c
16564Starting at line 1674 of /home/shackle/pggit/postgresql/src/backend/optimizer/prep/prepjointree.c
16565
16566 parse->targetList = (List *)
16567 pullup_replace_vars((Node *) parse->targetList, &rvcontext);
16568 parse->returningList = (List *)
16569 pullup_replace_vars((Node *) parse->returningList, &rvcontext);
16570 if (parse->onConflict)
16571 {
16572 parse->onConflict->onConflictSet = (List *)
16573 pullup_replace_vars((Node *) parse->onConflict->onConflictSet,
16574 &rvcontext);
16575 parse->onConflict->onConflictWhere =
16576 pullup_replace_vars(parse->onConflict->onConflictWhere,
16577 &rvcontext);
16578
16579 /*
16580 * We assume ON CONFLICT's arbiterElems, arbiterWhere, exclRelTlist
16581 * can't contain any references to a subquery
16582 */
16583 }
16584 replace_vars_in_jointree((Node *) parse->jointree, &rvcontext,
16585=====================================================================
16586Found a 41 line (109 tokens) duplication in the following files:
16587Starting at line 773 of /home/shackle/pggit/postgresql/src/backend/utils/mmgr/mcxt.c
16588Starting at line 928 of /home/shackle/pggit/postgresql/src/backend/utils/mmgr/mcxt.c
16589
16590 void *ret;
16591
16592 AssertArg(MemoryContextIsValid(context));
16593 AssertNotInCriticalSection(context);
16594
16595 if (!AllocSizeIsValid(size))
16596 elog(ERROR, "invalid memory alloc request size %zu", size);
16597
16598 context->isReset = false;
16599
16600 ret = context->methods->alloc(context, size);
16601 if (unlikely(ret == NULL))
16602 {
16603 MemoryContextStats(TopMemoryContext);
16604
16605 /*
16606 * Here, and elsewhere in this module, we show the target context's
16607 * "name" but not its "ident" (if any) in user-visible error messages.
16608 * The "ident" string might contain security-sensitive data, such as
16609 * values in SQL commands.
16610 */
16611 ereport(ERROR,
16612 (errcode(ERRCODE_OUT_OF_MEMORY),
16613 errmsg("out of memory"),
16614 errdetail("Failed on request of size %zu in memory context \"%s\".",
16615 size, context->name)));
16616 }
16617
16618 VALGRIND_MEMPOOL_ALLOC(context, ret, size);
16619
16620 return ret;
16621}
16622
16623/*
16624 * MemoryContextAllocZero
16625 * Like MemoryContextAlloc, but clears allocated memory
16626 *
16627 * We could just call MemoryContextAlloc then clear the memory, but this
16628 * is a very common combination, so we provide the combined operation.
16629 */
16630void *
16631=====================================================================
16632Found a 29 line (109 tokens) duplication in the following files:
16633Starting at line 445 of /home/shackle/pggit/postgresql/src/backend/access/nbtree/nbtpage.c
16634Starting at line 549 of /home/shackle/pggit/postgresql/src/backend/access/nbtree/nbtpage.c
16635
16636 _bt_cachemetadata(rel, metad);
16637
16638 /*
16639 * We are done with the metapage; arrange to release it via first
16640 * _bt_relandgetbuf call
16641 */
16642 rootbuf = metabuf;
16643
16644 for (;;)
16645 {
16646 rootbuf = _bt_relandgetbuf(rel, rootbuf, rootblkno, BT_READ);
16647 rootpage = BufferGetPage(rootbuf);
16648 rootopaque = (BTPageOpaque) PageGetSpecialPointer(rootpage);
16649
16650 if (!P_IGNORE(rootopaque))
16651 break;
16652
16653 /* it's dead, Jim. step right one page */
16654 if (P_RIGHTMOST(rootopaque))
16655 elog(ERROR, "no live root page found in index \"%s\"",
16656 RelationGetRelationName(rel));
16657 rootblkno = rootopaque->btpo_next;
16658 }
16659
16660 /* Note: can't check btpo.level on deleted pages */
16661 if (rootopaque->btpo.level != rootlevel)
16662 elog(ERROR, "root page %u of index \"%s\" has level %u, expected %u",
16663 rootblkno, RelationGetRelationName(rel),
16664 rootopaque->btpo.level, rootlevel);
16665=====================================================================
16666Found a 39 line (108 tokens) duplication in the following files:
16667Starting at line 623 of /home/shackle/pggit/postgresql/contrib/pg_trgm/trgm_gist.c
16668Starting at line 492 of /home/shackle/pggit/postgresql/src/backend/utils/adt/tsgistidx.c
16669
16670 if (CMPTRGM(ptra + i, ptrb + i))
16671 {
16672 *result = false;
16673 break;
16674 }
16675 }
16676 }
16677
16678 PG_RETURN_POINTER(result);
16679}
16680
16681static int32
16682sizebitvec(BITVECP sign)
16683{
16684 int32 size = 0,
16685 i;
16686
16687 LOOPBYTE
16688 size += number_of_ones[(unsigned char) sign[i]];
16689 return size;
16690}
16691
16692static int
16693hemdistsign(BITVECP a, BITVECP b)
16694{
16695 int i,
16696 diff,
16697 dist = 0;
16698
16699 LOOPBYTE
16700 {
16701 diff = (unsigned char) (a[i] ^ b[i]);
16702 dist += number_of_ones[diff];
16703 }
16704 return dist;
16705}
16706
16707static int
16708hemdist(TRGM *a, TRGM *b)
16709=====================================================================
16710Found a 29 line (108 tokens) duplication in the following files:
16711Starting at line 621 of /home/shackle/pggit/postgresql/contrib/pgcrypto/imath.c
16712Starting at line 713 of /home/shackle/pggit/postgresql/contrib/pgcrypto/imath.c
16713
16714 if (MP_SIGN(a) == MP_SIGN(b))
16715 {
16716 /* Same sign -- add magnitudes, preserve sign of addends */
16717 mp_digit carry;
16718
16719 if (!s_pad(c, max))
16720 return MP_MEMORY;
16721
16722 carry = s_uadd(MP_DIGITS(a), MP_DIGITS(b), MP_DIGITS(c), ua, ub);
16723 uc = max;
16724
16725 if (carry)
16726 {
16727 if (!s_pad(c, max + 1))
16728 return MP_MEMORY;
16729
16730 c->digits[max] = carry;
16731 ++uc;
16732 }
16733
16734 MP_USED(c) = uc;
16735 MP_SIGN(c) = MP_SIGN(a);
16736
16737 }
16738 else
16739 {
16740 /* Different signs -- subtract magnitudes, preserve sign of greater */
16741 mp_int x,
16742 y;
16743=====================================================================
16744Found a 34 line (108 tokens) duplication in the following files:
16745Starting at line 917 of /home/shackle/pggit/postgresql/src/bin/pg_dump/dumputils.c
16746Starting at line 3425 of /home/shackle/pggit/postgresql/src/backend/utils/adt/varlena.c
16747
16748 while (isspace((unsigned char) *nextp))
16749 nextp++; /* skip leading whitespace */
16750
16751 if (*nextp == '\0')
16752 return true; /* allow empty string */
16753
16754 /* At the top of the loop, we are at start of a new identifier. */
16755 do
16756 {
16757 char *curname;
16758 char *endp;
16759
16760 if (*nextp == '"')
16761 {
16762 /* Quoted name --- collapse quote-quote pairs */
16763 curname = nextp + 1;
16764 for (;;)
16765 {
16766 endp = strchr(nextp + 1, '"');
16767 if (endp == NULL)
16768 return false; /* mismatched quotes */
16769 if (endp[1] != '"')
16770 break; /* found end of quoted name */
16771 /* Collapse adjacent quotes into one quote, and look again */
16772 memmove(endp, endp + 1, strlen(endp));
16773 nextp = endp;
16774 }
16775 /* endp now points at the terminating quote */
16776 nextp = endp + 1;
16777 }
16778 else
16779 {
16780 /* Unquoted name --- extends to separator or whitespace */
16781 curname = nextp;
16782=====================================================================
16783Found a 3 line (108 tokens) duplication in the following files:
16784Starting at line 31 of /home/shackle/pggit/postgresql/src/common/base64.c
16785Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
16786Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
16787Starting at line 207 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
16788Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
16789
16790 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
16791 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
16792 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
16793=====================================================================
16794Found a 3 line (108 tokens) duplication in the following files:
16795Starting at line 31 of /home/shackle/pggit/postgresql/src/common/base64.c
16796Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
16797Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
16798Starting at line 207 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
16799Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
16800
16801 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
16802 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
16803 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
16804=====================================================================
16805Found a 5 line (108 tokens) duplication in the following files:
16806Starting at line 98 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
16807Starting at line 103 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
16808
16809 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
16810 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
16811 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
16812 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
16813 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
16814=====================================================================
16815Found a 27 line (108 tokens) duplication in the following files:
16816Starting at line 3428 of /home/shackle/pggit/postgresql/src/backend/utils/adt/jsonfuncs.c
16817Starting at line 3881 of /home/shackle/pggit/postgresql/src/backend/utils/adt/jsonfuncs.c
16818
16819 hashentry = hash_search(_state->hash, fname, HASH_ENTER, &found);
16820
16821 /*
16822 * found being true indicates a duplicate. We don't do anything about
16823 * that, a later field with the same name overrides the earlier field.
16824 */
16825
16826 hashentry->type = _state->saved_token_type;
16827 Assert(isnull == (hashentry->type == JSON_TOKEN_NULL));
16828
16829 if (_state->save_json_start != NULL)
16830 {
16831 int len = _state->lex->prev_token_terminator - _state->save_json_start;
16832 char *val = palloc((len + 1) * sizeof(char));
16833
16834 memcpy(val, _state->save_json_start, len);
16835 val[len] = '\0';
16836 hashentry->val = val;
16837 }
16838 else
16839 {
16840 /* must have had a scalar instead */
16841 hashentry->val = _state->saved_scalar;
16842 }
16843}
16844
16845static void
16846=====================================================================
16847Found a 38 line (108 tokens) duplication in the following files:
16848Starting at line 552 of /home/shackle/pggit/postgresql/src/backend/access/heap/heapam.c
16849Starting at line 853 of /home/shackle/pggit/postgresql/src/backend/access/heap/heapam.c
16850
16851 linesleft = lines - lineoff + 1;
16852 }
16853 else if (backward)
16854 {
16855 /* backward parallel scan not supported */
16856 Assert(scan->rs_parallel == NULL);
16857
16858 if (!scan->rs_inited)
16859 {
16860 /*
16861 * return null immediately if relation is empty
16862 */
16863 if (scan->rs_nblocks == 0 || scan->rs_numblocks == 0)
16864 {
16865 Assert(!BufferIsValid(scan->rs_cbuf));
16866 tuple->t_data = NULL;
16867 return;
16868 }
16869
16870 /*
16871 * Disable reporting to syncscan logic in a backwards scan; it's
16872 * not very likely anyone else is doing the same thing at the same
16873 * time, and much more likely that we'll just bollix things for
16874 * forward scanners.
16875 */
16876 scan->rs_syncscan = false;
16877 /* start from last page of the scan */
16878 if (scan->rs_startblock > 0)
16879 page = scan->rs_startblock - 1;
16880 else
16881 page = scan->rs_nblocks - 1;
16882 heapgetpage(scan, page);
16883 }
16884 else
16885 {
16886 /* continue from previously returned page/tuple */
16887 page = scan->rs_cblock; /* current page */
16888 }
16889=====================================================================
16890Found a 35 line (108 tokens) duplication in the following files:
16891Starting at line 231 of /home/shackle/pggit/postgresql/src/backend/access/transam/xloginsert.c
16892Starting at line 286 of /home/shackle/pggit/postgresql/src/backend/access/transam/xloginsert.c
16893
16894 regbuf->page = BufferGetPage(buffer);
16895 regbuf->flags = flags;
16896 regbuf->rdata_tail = (XLogRecData *) ®buf->rdata_head;
16897 regbuf->rdata_len = 0;
16898
16899 /*
16900 * Check that this page hasn't already been registered with some other
16901 * block_id.
16902 */
16903#ifdef USE_ASSERT_CHECKING
16904 {
16905 int i;
16906
16907 for (i = 0; i < max_registered_block_id; i++)
16908 {
16909 registered_buffer *regbuf_old = ®istered_buffers[i];
16910
16911 if (i == block_id || !regbuf_old->in_use)
16912 continue;
16913
16914 Assert(!RelFileNodeEquals(regbuf_old->rnode, regbuf->rnode) ||
16915 regbuf_old->forkno != regbuf->forkno ||
16916 regbuf_old->block != regbuf->block);
16917 }
16918 }
16919#endif
16920
16921 regbuf->in_use = true;
16922}
16923
16924/*
16925 * Like XLogRegisterBuffer, but for registering a block that's not in the
16926 * shared buffer pool (i.e. when you don't have a Buffer for it).
16927 */
16928void
16929=====================================================================
16930Found a 26 line (107 tokens) duplication in the following files:
16931Starting at line 178 of /home/shackle/pggit/postgresql/contrib/pageinspect/btreefuncs.c
16932Starting at line 332 of /home/shackle/pggit/postgresql/contrib/pageinspect/btreefuncs.c
16933
16934 (errmsg("must be superuser to use pageinspect functions"))));
16935
16936 relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
16937 rel = relation_openrv(relrv, AccessShareLock);
16938
16939 if (!IS_INDEX(rel) || !IS_BTREE(rel))
16940 elog(ERROR, "relation \"%s\" is not a btree index",
16941 RelationGetRelationName(rel));
16942
16943 /*
16944 * Reject attempts to read non-local temporary relations; we would be
16945 * likely to get wrong data since we have no visibility into the owning
16946 * session's local buffers.
16947 */
16948 if (RELATION_IS_OTHER_TEMP(rel))
16949 ereport(ERROR,
16950 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
16951 errmsg("cannot access temporary tables of other sessions")));
16952
16953 if (blkno == 0)
16954 elog(ERROR, "block 0 is a meta page");
16955
16956 CHECK_RELATION_BLOCK_RANGE(rel, blkno);
16957
16958 buffer = ReadBuffer(rel, blkno);
16959 LockBuffer(buffer, BUFFER_LOCK_SHARE);
16960=====================================================================
16961Found a 27 line (107 tokens) duplication in the following files:
16962Starting at line 614 of /home/shackle/pggit/postgresql/src/bin/initdb/initdb.c
16963Starting at line 177 of /home/shackle/pggit/postgresql/src/bin/pg_basebackup/pg_basebackup.c
16964
16965 if (!rmtree(pg_data, false))
16966 fprintf(stderr, _("%s: failed to remove contents of data directory\n"),
16967 progname);
16968 }
16969
16970 if (made_new_xlogdir)
16971 {
16972 fprintf(stderr, _("%s: removing WAL directory \"%s\"\n"),
16973 progname, xlog_dir);
16974 if (!rmtree(xlog_dir, true))
16975 fprintf(stderr, _("%s: failed to remove WAL directory\n"),
16976 progname);
16977 }
16978 else if (found_existing_xlogdir)
16979 {
16980 fprintf(stderr,
16981 _("%s: removing contents of WAL directory \"%s\"\n"),
16982 progname, xlog_dir);
16983 if (!rmtree(xlog_dir, false))
16984 fprintf(stderr, _("%s: failed to remove contents of WAL directory\n"),
16985 progname);
16986 }
16987 /* otherwise died during startup, do nothing! */
16988 }
16989 else
16990 {
16991 if (made_new_pgdata || found_existing_pgdata)
16992=====================================================================
16993Found a 29 line (107 tokens) duplication in the following files:
16994Starting at line 199 of /home/shackle/pggit/postgresql/src/include/catalog/pg_constraint.h
16995Starting at line 56 of /home/shackle/pggit/postgresql/src/backend/catalog/pg_constraint.c
16996
16997extern Oid CreateConstraintEntry(const char *constraintName,
16998 Oid constraintNamespace,
16999 char constraintType,
17000 bool isDeferrable,
17001 bool isDeferred,
17002 bool isValidated,
17003 Oid parentConstrId,
17004 Oid relId,
17005 const int16 *constraintKey,
17006 int constraintNKeys,
17007 int constraintNTotalKeys,
17008 Oid domainId,
17009 Oid indexRelId,
17010 Oid foreignRelId,
17011 const int16 *foreignKey,
17012 const Oid *pfEqOp,
17013 const Oid *ppEqOp,
17014 const Oid *ffEqOp,
17015 int foreignNKeys,
17016 char foreignUpdateType,
17017 char foreignDeleteType,
17018 char foreignMatchType,
17019 const Oid *exclOp,
17020 Node *conExpr,
17021 const char *conBin,
17022 bool conIsLocal,
17023 int conInhCount,
17024 bool conNoInherit,
17025 bool is_internal);
17026=====================================================================
17027Found a 26 line (107 tokens) duplication in the following files:
17028Starting at line 570 of /home/shackle/pggit/postgresql/src/pl/plpgsql/src/pl_exec.c
17029Starting at line 940 of /home/shackle/pggit/postgresql/src/pl/plpgsql/src/pl_exec.c
17030
17031 estate.err_text = gettext_noop("during function entry");
17032
17033 /*
17034 * Set the magic variable FOUND to false
17035 */
17036 exec_set_found(&estate, false);
17037
17038 /*
17039 * Let the instrumentation plugin peek at this function
17040 */
17041 if (*plpgsql_plugin_ptr && (*plpgsql_plugin_ptr)->func_beg)
17042 ((*plpgsql_plugin_ptr)->func_beg) (&estate, func);
17043
17044 /*
17045 * Now call the toplevel block of statements
17046 */
17047 estate.err_text = NULL;
17048 estate.err_stmt = (PLpgSQL_stmt *) (func->action);
17049 rc = exec_stmt_block(&estate, func->action);
17050 if (rc != PLPGSQL_RC_RETURN)
17051 {
17052 estate.err_stmt = NULL;
17053 estate.err_text = NULL;
17054 ereport(ERROR,
17055 (errcode(ERRCODE_S_R_E_FUNCTION_EXECUTED_NO_RETURN_STATEMENT),
17056 errmsg("control reached end of function without RETURN")));
17057=====================================================================
17058Found a 41 line (107 tokens) duplication in the following files:
17059Starting at line 306 of /home/shackle/pggit/postgresql/src/pl/plpython/plpy_typeio.c
17060Starting at line 429 of /home/shackle/pggit/postgresql/src/pl/plpython/plpy_typeio.c
17061
17062 Oid typinput;
17063
17064 /* Since this is recursive, it could theoretically be driven to overflow */
17065 check_stack_depth();
17066
17067 arg->typoid = typeOid;
17068 arg->typmod = typmod;
17069 arg->mcxt = arg_mcxt;
17070
17071 /*
17072 * Fetch typcache entry for the target type, asking for whatever info
17073 * we'll need later. RECORD is a special case: just treat it as composite
17074 * without bothering with the typcache entry.
17075 */
17076 if (typeOid != RECORDOID)
17077 {
17078 typentry = lookup_type_cache(typeOid, TYPECACHE_DOMAIN_BASE_INFO);
17079 typtype = typentry->typtype;
17080 arg->typbyval = typentry->typbyval;
17081 arg->typlen = typentry->typlen;
17082 arg->typalign = typentry->typalign;
17083 }
17084 else
17085 {
17086 typentry = NULL;
17087 typtype = TYPTYPE_COMPOSITE;
17088 /* hard-wired knowledge about type RECORD: */
17089 arg->typbyval = false;
17090 arg->typlen = -1;
17091 arg->typalign = 'd';
17092 }
17093
17094 /*
17095 * Choose conversion method. Note that transform functions are checked
17096 * for composite and scalar types, but not for arrays or domains. This is
17097 * somewhat historical, but we'd have a problem allowing them on domains,
17098 * since we drill down through all levels of a domain nest without looking
17099 * at the intermediate levels at all.
17100 */
17101 if (typtype == TYPTYPE_DOMAIN)
17102 {
17103=====================================================================
17104Found a 48 line (107 tokens) duplication in the following files:
17105Starting at line 28 of /home/shackle/pggit/postgresql/src/test/examples/testlibpq.c
17106Starting at line 57 of /home/shackle/pggit/postgresql/src/test/examples/testlibpq2.c
17107
17108 j;
17109
17110 /*
17111 * If the user supplies a parameter on the command line, use it as the
17112 * conninfo string; otherwise default to setting dbname=postgres and using
17113 * environment variables or defaults for all other connection parameters.
17114 */
17115 if (argc > 1)
17116 conninfo = argv[1];
17117 else
17118 conninfo = "dbname = postgres";
17119
17120 /* Make a connection to the database */
17121 conn = PQconnectdb(conninfo);
17122
17123 /* Check to see that the backend connection was successfully made */
17124 if (PQstatus(conn) != CONNECTION_OK)
17125 {
17126 fprintf(stderr, "Connection to database failed: %s",
17127 PQerrorMessage(conn));
17128 exit_nicely(conn);
17129 }
17130
17131 /* Set always-secure search path, so malicious users can't take control. */
17132 res = PQexec(conn,
17133 "SELECT pg_catalog.set_config('search_path', '', false)");
17134 if (PQresultStatus(res) != PGRES_TUPLES_OK)
17135 {
17136 fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
17137 PQclear(res);
17138 exit_nicely(conn);
17139 }
17140
17141 /*
17142 * Should PQclear PGresult whenever it is no longer needed to avoid memory
17143 * leaks
17144 */
17145 PQclear(res);
17146
17147 /*
17148 * Our test case here involves using a cursor, for which we must be inside
17149 * a transaction block. We could do the whole thing with a single
17150 * PQexec() of "select * from pg_database", but that's too trivial to make
17151 * a good example.
17152 */
17153
17154 /* Start a transaction block */
17155 res = PQexec(conn, "BEGIN");
17156=====================================================================
17157Found a 36 line (107 tokens) duplication in the following files:
17158Starting at line 752 of /home/shackle/pggit/postgresql/src/backend/regex/regc_nfa.c
17159Starting at line 841 of /home/shackle/pggit/postgresql/src/backend/regex/regc_nfa.c
17160
17161 }
17162 else
17163 {
17164 /*
17165 * With many arcs, use a sort-merge approach. Note changearctarget()
17166 * will put the arc onto the front of newState's chain, so it does not
17167 * break our walk through the sorted part of the chain.
17168 */
17169 struct arc *oa;
17170 struct arc *na;
17171
17172 /*
17173 * Because we bypass newarc() in this code path, we'd better include a
17174 * cancel check.
17175 */
17176 if (CANCEL_REQUESTED(nfa->v->re))
17177 {
17178 NERR(REG_CANCEL);
17179 return;
17180 }
17181
17182 sortins(nfa, oldState);
17183 sortins(nfa, newState);
17184 if (NISERR())
17185 return; /* might have failed to sort */
17186 oa = oldState->ins;
17187 na = newState->ins;
17188 while (oa != NULL && na != NULL)
17189 {
17190 struct arc *a = oa;
17191
17192 switch (sortins_cmp(&oa, &na))
17193 {
17194 case -1:
17195 /* newState does not have anything matching oa */
17196 oa = oa->inchain;
17197=====================================================================
17198Found a 24 line (107 tokens) duplication in the following files:
17199Starting at line 367 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c
17200Starting at line 471 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c
17201
17202 int c1;
17203 int l;
17204
17205 while (len > 0)
17206 {
17207 c1 = *euc;
17208 if (!IS_HIGHBIT_SET(c1))
17209 {
17210 /* ASCII */
17211 if (c1 == 0)
17212 report_invalid_encoding(PG_EUC_JP,
17213 (const char *) euc, len);
17214 *p++ = c1;
17215 euc++;
17216 len--;
17217 continue;
17218 }
17219 l = pg_encoding_verifymb(PG_EUC_JP, (const char *) euc, len);
17220 if (l < 0)
17221 report_invalid_encoding(PG_EUC_JP,
17222 (const char *) euc, len);
17223 if (c1 == SS2)
17224 { /* 1 byte kana? */
17225 *p++ = LC_JISX0201K;
17226=====================================================================
17227Found a 50 line (107 tokens) duplication in the following files:
17228Starting at line 6625 of /home/shackle/pggit/postgresql/src/backend/utils/adt/numeric.c
17229Starting at line 6742 of /home/shackle/pggit/postgresql/src/backend/utils/adt/numeric.c
17230
17231 if (var2->sign == NUMERIC_POS)
17232 {
17233 /*
17234 * Both are positive result = +(ABS(var1) + ABS(var2))
17235 */
17236 add_abs(var1, var2, result);
17237 result->sign = NUMERIC_POS;
17238 }
17239 else
17240 {
17241 /*
17242 * var1 is positive, var2 is negative Must compare absolute values
17243 */
17244 switch (cmp_abs(var1, var2))
17245 {
17246 case 0:
17247 /* ----------
17248 * ABS(var1) == ABS(var2)
17249 * result = ZERO
17250 * ----------
17251 */
17252 zero_var(result);
17253 result->dscale = Max(var1->dscale, var2->dscale);
17254 break;
17255
17256 case 1:
17257 /* ----------
17258 * ABS(var1) > ABS(var2)
17259 * result = +(ABS(var1) - ABS(var2))
17260 * ----------
17261 */
17262 sub_abs(var1, var2, result);
17263 result->sign = NUMERIC_POS;
17264 break;
17265
17266 case -1:
17267 /* ----------
17268 * ABS(var1) < ABS(var2)
17269 * result = -(ABS(var2) - ABS(var1))
17270 * ----------
17271 */
17272 sub_abs(var2, var1, result);
17273 result->sign = NUMERIC_NEG;
17274 break;
17275 }
17276 }
17277 }
17278 else
17279 {
17280 if (var2->sign == NUMERIC_POS)
17281=====================================================================
17282Found a 38 line (107 tokens) duplication in the following files:
17283Starting at line 2163 of /home/shackle/pggit/postgresql/src/backend/utils/adt/float.c
17284Starting at line 2227 of /home/shackle/pggit/postgresql/src/backend/utils/adt/float.c
17285Starting at line 2282 of /home/shackle/pggit/postgresql/src/backend/utils/adt/float.c
17286
17287 volatile float8 cot_arg1;
17288 int sign = 1;
17289
17290 /*
17291 * Per the POSIX spec, return NaN if the input is NaN and throw an error
17292 * if the input is infinite.
17293 */
17294 if (isnan(arg1))
17295 PG_RETURN_FLOAT8(get_float8_nan());
17296
17297 if (isinf(arg1))
17298 ereport(ERROR,
17299 (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
17300 errmsg("input is out of range")));
17301
17302 INIT_DEGREE_CONSTANTS();
17303
17304 /* Reduce the range of the input to [0,90] degrees */
17305 arg1 = fmod(arg1, 360.0);
17306
17307 if (arg1 < 0.0)
17308 {
17309 /* cotd(-x) = -cotd(x) */
17310 arg1 = -arg1;
17311 sign = -sign;
17312 }
17313
17314 if (arg1 > 180.0)
17315 {
17316 /* cotd(360-x) = -cotd(x) */
17317 arg1 = 360.0 - arg1;
17318 sign = -sign;
17319 }
17320
17321 if (arg1 > 90.0)
17322 {
17323 /* cotd(180-x) = -cotd(x) */
17324 arg1 = 180.0 - arg1;
17325=====================================================================
17326Found a 30 line (107 tokens) duplication in the following files:
17327Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/enum.c
17328Starting at line 183 of /home/shackle/pggit/postgresql/src/backend/utils/adt/enum.c
17329
17330 HeapTuple tup;
17331
17332 /* must check length to prevent Assert failure within SearchSysCache */
17333 if (strlen(name) >= NAMEDATALEN)
17334 ereport(ERROR,
17335 (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
17336 errmsg("invalid input value for enum %s: \"%s\"",
17337 format_type_be(enumtypoid),
17338 name)));
17339
17340 tup = SearchSysCache2(ENUMTYPOIDNAME,
17341 ObjectIdGetDatum(enumtypoid),
17342 CStringGetDatum(name));
17343 if (!HeapTupleIsValid(tup))
17344 ereport(ERROR,
17345 (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
17346 errmsg("invalid input value for enum %s: \"%s\"",
17347 format_type_be(enumtypoid),
17348 name)));
17349
17350 /* check it's safe to use in SQL */
17351 check_safe_enum_use(tup);
17352
17353 /*
17354 * This comes from pg_enum.oid and stores system oids in user tables. This
17355 * oid must be preserved by binary upgrades.
17356 */
17357 enumoid = ((Form_pg_enum) GETSTRUCT(tup))->oid;
17358
17359 ReleaseSysCache(tup);
17360=====================================================================
17361Found a 26 line (107 tokens) duplication in the following files:
17362Starting at line 126 of /home/shackle/pggit/postgresql/src/backend/utils/adt/numutils.c
17363Starting at line 202 of /home/shackle/pggit/postgresql/src/backend/utils/adt/numutils.c
17364
17365 int16 tmp = 0;
17366 bool neg = false;
17367
17368 /* skip leading spaces */
17369 while (likely(*ptr) && isspace((unsigned char) *ptr))
17370 ptr++;
17371
17372 /* handle sign */
17373 if (*ptr == '-')
17374 {
17375 ptr++;
17376 neg = true;
17377 }
17378 else if (*ptr == '+')
17379 ptr++;
17380
17381 /* require at least one digit */
17382 if (unlikely(!isdigit((unsigned char) *ptr)))
17383 goto invalid_syntax;
17384
17385 /* process digits */
17386 while (*ptr && isdigit((unsigned char) *ptr))
17387 {
17388 int8 digit = (*ptr++ - '0');
17389
17390 if (unlikely(pg_mul_s16_overflow(tmp, 10, &tmp)) ||
17391=====================================================================
17392Found a 26 line (107 tokens) duplication in the following files:
17393Starting at line 390 of /home/shackle/pggit/postgresql/src/backend/utils/adt/ri_triggers.c
17394Starting at line 526 of /home/shackle/pggit/postgresql/src/backend/utils/adt/ri_triggers.c
17395
17396 ri_BuildQueryKey(&qkey, riinfo, RI_PLAN_CHECK_LOOKUPPK);
17397
17398 if ((qplan = ri_FetchPreparedPlan(&qkey)) == NULL)
17399 {
17400 StringInfoData querybuf;
17401 char pkrelname[MAX_QUOTED_REL_NAME_LEN];
17402 char attname[MAX_QUOTED_NAME_LEN];
17403 char paramname[16];
17404 const char *querysep;
17405 Oid queryoids[RI_MAX_NUMKEYS];
17406
17407 /* ----------
17408 * The query string built is
17409 * SELECT 1 FROM ONLY <pktable> x WHERE pkatt1 = $1 [AND ...]
17410 * FOR KEY SHARE OF x
17411 * The type id's for the $ parameters are those of the
17412 * corresponding FK attributes.
17413 * ----------
17414 */
17415 initStringInfo(&querybuf);
17416 quoteRelationName(pkrelname, pk_rel);
17417 appendStringInfo(&querybuf, "SELECT 1 FROM ONLY %s x", pkrelname);
17418 querysep = "WHERE";
17419 for (i = 0; i < riinfo->nkeys; i++)
17420 {
17421 Oid pk_type = RIAttType(pk_rel, riinfo->pk_attnums[i]);
17422=====================================================================
17423Found a 22 line (106 tokens) duplication in the following files:
17424Starting at line 459 of /home/shackle/pggit/postgresql/contrib/ltree/ltxtquery_io.c
17425Starting at line 585 of /home/shackle/pggit/postgresql/contrib/intarray/_int_bool.c
17426
17427 in->curpol++;
17428 if (in->curpol->type == OPR)
17429 {
17430 isopr = true;
17431 RESIZEBUF(in, 2);
17432 sprintf(in->cur, "( ");
17433 in->cur = strchr(in->cur, '\0');
17434 }
17435 infix(in, isopr);
17436 if (isopr)
17437 {
17438 RESIZEBUF(in, 2);
17439 sprintf(in->cur, " )");
17440 in->cur = strchr(in->cur, '\0');
17441 }
17442 }
17443 else
17444 {
17445 int32 op = in->curpol->val;
17446 INFIX nrm;
17447
17448 in->curpol++;
17449=====================================================================
17450Found a 18 line (106 tokens) duplication in the following files:
17451Starting at line 136 of /home/shackle/pggit/postgresql/contrib/ltree/_ltree_op.c
17452Starting at line 341 of /home/shackle/pggit/postgresql/contrib/ltree/lquery_op.c
17453
17454 ArrayType *_tree = PG_GETARG_ARRAYTYPE_P(0);
17455 ArrayType *_query = PG_GETARG_ARRAYTYPE_P(1);
17456 lquery *query = (lquery *) ARR_DATA_PTR(_query);
17457 bool res = false;
17458 int num = ArrayGetNItems(ARR_NDIM(_query), ARR_DIMS(_query));
17459
17460 if (ARR_NDIM(_query) > 1)
17461 ereport(ERROR,
17462 (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
17463 errmsg("array must be one-dimensional")));
17464 if (array_contains_nulls(_query))
17465 ereport(ERROR,
17466 (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
17467 errmsg("array must not contain nulls")));
17468
17469 while (num > 0)
17470 {
17471 if (array_iterator(_tree, ltq_regex, (void *) query, NULL))
17472=====================================================================
17473Found a 47 line (106 tokens) duplication in the following files:
17474Starting at line 348 of /home/shackle/pggit/postgresql/contrib/tsm_system_rows/tsm_system_rows.c
17475Starting at line 309 of /home/shackle/pggit/postgresql/contrib/tsm_system_time/tsm_system_time.c
17476
17477 return false;
17478}
17479
17480/*
17481 * Compute greatest common divisor of two uint32's.
17482 */
17483static uint32
17484gcd(uint32 a, uint32 b)
17485{
17486 uint32 c;
17487
17488 while (a != 0)
17489 {
17490 c = a;
17491 a = b % a;
17492 b = c;
17493 }
17494
17495 return b;
17496}
17497
17498/*
17499 * Pick a random value less than and relatively prime to n, if possible
17500 * (else return 1).
17501 */
17502static uint32
17503random_relative_prime(uint32 n, SamplerRandomState randstate)
17504{
17505 uint32 r;
17506
17507 /* Safety check to avoid infinite loop or zero result for small n. */
17508 if (n <= 1)
17509 return 1;
17510
17511 /*
17512 * This should only take 2 or 3 iterations as the probability of 2 numbers
17513 * being relatively prime is ~61%; but just in case, we'll include a
17514 * CHECK_FOR_INTERRUPTS in the loop.
17515 */
17516 do
17517 {
17518 CHECK_FOR_INTERRUPTS();
17519 r = (uint32) (sampler_random_fract(randstate) * n);
17520 } while (r == 0 || gcd(r, n) > 1);
17521
17522 return r;
17523}
17524=====================================================================
17525Found a 32 line (106 tokens) duplication in the following files:
17526Starting at line 917 of /home/shackle/pggit/postgresql/src/bin/pg_dump/dumputils.c
17527Starting at line 3298 of /home/shackle/pggit/postgresql/src/backend/utils/adt/varlena.c
17528
17529 while (isspace((unsigned char) *nextp))
17530 nextp++; /* skip leading whitespace */
17531
17532 if (*nextp == '\0')
17533 return true; /* allow empty string */
17534
17535 /* At the top of the loop, we are at start of a new identifier. */
17536 do
17537 {
17538 char *curname;
17539 char *endp;
17540
17541 if (*nextp == '"')
17542 {
17543 /* Quoted name --- collapse quote-quote pairs */
17544 curname = nextp + 1;
17545 for (;;)
17546 {
17547 endp = strchr(nextp + 1, '"');
17548 if (endp == NULL)
17549 return false; /* mismatched quotes */
17550 if (endp[1] != '"')
17551 break; /* found end of quoted name */
17552 /* Collapse adjacent quotes into one quote, and look again */
17553 memmove(endp, endp + 1, strlen(endp));
17554 nextp = endp;
17555 }
17556 /* endp now points at the terminating quote */
17557 nextp = endp + 1;
17558 }
17559 else
17560 {
17561=====================================================================
17562Found a 22 line (106 tokens) duplication in the following files:
17563Starting at line 415 of /home/shackle/pggit/postgresql/src/pl/plpgsql/src/pl_handler.c
17564Starting at line 1989 of /home/shackle/pggit/postgresql/src/pl/plperl/plperl.c
17565
17566 bool is_dml_trigger = false;
17567 bool is_event_trigger = false;
17568 int i;
17569
17570 if (!CheckFunctionValidatorAccess(fcinfo->flinfo->fn_oid, funcoid))
17571 PG_RETURN_VOID();
17572
17573 /* Get the new function's pg_proc entry */
17574 tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcoid));
17575 if (!HeapTupleIsValid(tuple))
17576 elog(ERROR, "cache lookup failed for function %u", funcoid);
17577 proc = (Form_pg_proc) GETSTRUCT(tuple);
17578
17579 functyptype = get_typtype(proc->prorettype);
17580
17581 /* Disallow pseudotype result */
17582 /* except for TRIGGER, RECORD, VOID, or polymorphic */
17583 if (functyptype == TYPTYPE_PSEUDO)
17584 {
17585 /* we assume OPAQUE with no arguments means a trigger */
17586 if (proc->prorettype == TRIGGEROID ||
17587 (proc->prorettype == OPAQUEOID && proc->pronargs == 0))
17588=====================================================================
17589Found a 23 line (106 tokens) duplication in the following files:
17590Starting at line 678 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/interval.c
17591Starting at line 4185 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
17592
17593 return 0;
17594}
17595
17596
17597/* copy&pasted from .../src/backend/utils/adt/datetime.c */
17598static char *
17599AddVerboseIntPart(char *cp, int value, const char *units,
17600 bool *is_zero, bool *is_before)
17601{
17602 if (value == 0)
17603 return cp;
17604 /* first nonzero value sets is_before */
17605 if (*is_zero)
17606 {
17607 *is_before = (value < 0);
17608 value = abs(value);
17609 }
17610 else if (*is_before)
17611 value = -value;
17612 sprintf(cp, " %d %s%s", value, units, (value == 1) ? "" : "s");
17613 *is_zero = false;
17614 return cp + strlen(cp);
17615}
17616=====================================================================
17617Found a 11 line (106 tokens) duplication in the following files:
17618Starting at line 313 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-desc.c
17619Starting at line 332 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-desc.c
17620
17621 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch next from c2", ECPGt_EOIT,
17622 ECPGt_int,&(val1output),(long)1,(long)1,sizeof(int),
17623 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
17624 ECPGt_char,(val2output),(long)sizeof("AAA"),(long)1,(sizeof("AAA"))*sizeof(char),
17625 ECPGt_int,&(val2i),(long)1,(long)1,sizeof(int), ECPGt_EORT);
17626#line 73 "desc.pgc"
17627
17628if (sqlca.sqlcode < 0) sqlprint();}
17629#line 73 "desc.pgc"
17630
17631 printf("val1=%d val2=%s\n", val1output, val2i ? "null" : val2output);
17632=====================================================================
17633Found a 19 line (106 tokens) duplication in the following files:
17634Starting at line 731 of /home/shackle/pggit/postgresql/src/backend/storage/page/bufpage.c
17635Starting at line 960 of /home/shackle/pggit/postgresql/src/backend/storage/page/bufpage.c
17636
17637 int offidx;
17638 int nline;
17639
17640 /*
17641 * As with PageRepairFragmentation, paranoia seems justified.
17642 */
17643 if (phdr->pd_lower < SizeOfPageHeaderData ||
17644 phdr->pd_lower > phdr->pd_upper ||
17645 phdr->pd_upper > phdr->pd_special ||
17646 phdr->pd_special > BLCKSZ ||
17647 phdr->pd_special != MAXALIGN(phdr->pd_special))
17648 ereport(ERROR,
17649 (errcode(ERRCODE_DATA_CORRUPTED),
17650 errmsg("corrupted page pointers: lower = %u, upper = %u, special = %u",
17651 phdr->pd_lower, phdr->pd_upper, phdr->pd_special)));
17652
17653 nline = PageGetMaxOffsetNumber(page);
17654 if ((int) offnum <= 0 || (int) offnum > nline)
17655 elog(ERROR, "invalid index offnum: %u", offnum);
17656=====================================================================
17657Found a 17 line (106 tokens) duplication in the following files:
17658Starting at line 1079 of /home/shackle/pggit/postgresql/src/backend/regex/regexec.c
17659Starting at line 1280 of /home/shackle/pggit/postgresql/src/backend/regex/regexec.c
17660
17661 max_matches = end - begin;
17662 if (max_matches > t->max && t->max != DUPINF)
17663 max_matches = t->max;
17664 if (max_matches < min_matches)
17665 max_matches = min_matches;
17666 endpts = (chr **) MALLOC((max_matches + 1) * sizeof(chr *));
17667 if (endpts == NULL)
17668 return REG_ESPACE;
17669 endpts[0] = begin;
17670
17671 d = getsubdfa(v, t->left);
17672 if (ISERR())
17673 {
17674 FREE(endpts);
17675 return v->err;
17676 }
17677 MDEBUG(("citer %d\n", t->id));
17678=====================================================================
17679Found a 5 line (106 tokens) duplication in the following files:
17680Starting at line 98 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
17681Starting at line 103 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
17682
17683 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
17684 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
17685 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
17686 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
17687 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
17688=====================================================================
17689Found a 23 line (106 tokens) duplication in the following files:
17690Starting at line 69 of /home/shackle/pggit/postgresql/src/backend/commands/policy.c
17691Starting at line 13368 of /home/shackle/pggit/postgresql/src/backend/commands/tablecmds.c
17692
17693 Form_pg_class classform;
17694 char relkind;
17695
17696 tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
17697 if (!HeapTupleIsValid(tuple))
17698 return;
17699
17700 classform = (Form_pg_class) GETSTRUCT(tuple);
17701 relkind = classform->relkind;
17702
17703 /* Must own relation. */
17704 if (!pg_class_ownercheck(relid, GetUserId()))
17705 aclcheck_error(ACLCHECK_NOT_OWNER, get_relkind_objtype(get_rel_relkind(relid)), rv->relname);
17706
17707 /* No system table modifications unless explicitly allowed. */
17708 if (!allowSystemTableMods && IsSystemClass(relid, classform))
17709 ereport(ERROR,
17710 (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
17711 errmsg("permission denied: \"%s\" is a system catalog",
17712 rv->relname)));
17713
17714 /* Relation type MUST be a table. */
17715 if (relkind != RELKIND_RELATION && relkind != RELKIND_PARTITIONED_TABLE)
17716=====================================================================
17717Found a 16 line (105 tokens) duplication in the following files:
17718Starting at line 146 of /home/shackle/pggit/postgresql/contrib/jsonb_plpython/jsonb_plpython.c
17719Starting at line 68 of /home/shackle/pggit/postgresql/contrib/jsonb_plperl/jsonb_plperl.c
17720
17721 PyObject *result;
17722
17723 it = JsonbIteratorInit(jsonb);
17724 r = JsonbIteratorNext(&it, &v, true);
17725
17726 switch (r)
17727 {
17728 case WJB_BEGIN_ARRAY:
17729 if (v.val.array.rawScalar)
17730 {
17731 JsonbValue tmp;
17732
17733 if ((r = JsonbIteratorNext(&it, &v, true)) != WJB_ELEM ||
17734 (r = JsonbIteratorNext(&it, &tmp, true)) != WJB_END_ARRAY ||
17735 (r = JsonbIteratorNext(&it, &tmp, true)) != WJB_DONE)
17736 elog(ERROR, "unexpected jsonb token: %d", r);
17737=====================================================================
17738Found a 20 line (105 tokens) duplication in the following files:
17739Starting at line 139 of /home/shackle/pggit/postgresql/src/pl/plpython/plpy_resultobject.c
17740Starting at line 165 of /home/shackle/pggit/postgresql/src/pl/plpython/plpy_resultobject.c
17741
17742PLy_result_coltypes(PyObject *self, PyObject *unused)
17743{
17744 PLyResultObject *ob = (PLyResultObject *) self;
17745 PyObject *list;
17746 int i;
17747
17748 if (!ob->tupdesc)
17749 {
17750 PLy_exception_set(PLy_exc_error, "command did not produce a result set");
17751 return NULL;
17752 }
17753
17754 list = PyList_New(ob->tupdesc->natts);
17755 if (!list)
17756 return NULL;
17757 for (i = 0; i < ob->tupdesc->natts; i++)
17758 {
17759 Form_pg_attribute attr = TupleDescAttr(ob->tupdesc, i);
17760
17761 PyList_SET_ITEM(list, i, PyInt_FromLong(attr->atttypid));
17762=====================================================================
17763Found a 3 line (105 tokens) duplication in the following files:
17764Starting at line 31 of /home/shackle/pggit/postgresql/src/common/base64.c
17765Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
17766Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
17767Starting at line 207 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
17768Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
17769
17770 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
17771 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
17772 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
17773=====================================================================
17774Found a 3 line (105 tokens) duplication in the following files:
17775Starting at line 31 of /home/shackle/pggit/postgresql/src/common/base64.c
17776Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
17777Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
17778Starting at line 207 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
17779Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
17780
17781 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
17782 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
17783 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
17784=====================================================================
17785Found a 30 line (105 tokens) duplication in the following files:
17786Starting at line 5577 of /home/shackle/pggit/postgresql/src/backend/catalog/aclchk.c
17787Starting at line 5863 of /home/shackle/pggit/postgresql/src/backend/catalog/aclchk.c
17788
17789 bool isNull;
17790 HeapTuple tuple;
17791
17792 tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(objoid));
17793 if (!HeapTupleIsValid(tuple))
17794 elog(ERROR, "cache lookup failed for relation %u", objoid);
17795 pg_class_tuple = (Form_pg_class) GETSTRUCT(tuple);
17796
17797 /* Indexes don't have permissions */
17798 if (pg_class_tuple->relkind == RELKIND_INDEX ||
17799 pg_class_tuple->relkind == RELKIND_PARTITIONED_INDEX)
17800 return;
17801
17802 /* Composite types don't have permissions either */
17803 if (pg_class_tuple->relkind == RELKIND_COMPOSITE_TYPE)
17804 return;
17805
17806 /*
17807 * If this isn't a sequence, index, or composite type then it's
17808 * possibly going to have columns associated with it that might have
17809 * ACLs.
17810 */
17811 if (pg_class_tuple->relkind != RELKIND_SEQUENCE)
17812 {
17813 AttrNumber curr_att;
17814 AttrNumber nattrs = pg_class_tuple->relnatts;
17815
17816 for (curr_att = 1; curr_att <= nattrs; curr_att++)
17817 {
17818 HeapTuple attTuple;
17819=====================================================================
17820Found a 29 line (105 tokens) duplication in the following files:
17821Starting at line 3625 of /home/shackle/pggit/postgresql/src/backend/utils/adt/numeric.c
17822Starting at line 3712 of /home/shackle/pggit/postgresql/src/backend/utils/adt/numeric.c
17823
17824 accum_sum_copy(&state1->sumX2, &state2->sumX2);
17825
17826 MemoryContextSwitchTo(old_context);
17827
17828 PG_RETURN_POINTER(state1);
17829 }
17830
17831 if (state2->N > 0)
17832 {
17833 state1->N += state2->N;
17834 state1->NaNcount += state2->NaNcount;
17835
17836 /*
17837 * These are currently only needed for moving aggregates, but let's do
17838 * the right thing anyway...
17839 */
17840 if (state2->maxScale > state1->maxScale)
17841 {
17842 state1->maxScale = state2->maxScale;
17843 state1->maxScaleCount = state2->maxScaleCount;
17844 }
17845 else if (state2->maxScale == state1->maxScale)
17846 state1->maxScaleCount += state2->maxScaleCount;
17847
17848 /* The rest of this needs to work in the aggregate context */
17849 old_context = MemoryContextSwitchTo(agg_context);
17850
17851 /* Accumulate sums */
17852 accum_sum_combine(&state1->sumX, &state2->sumX);
17853=====================================================================
17854Found a 14 line (105 tokens) duplication in the following files:
17855Starting at line 1244 of /home/shackle/pggit/postgresql/src/backend/utils/adt/timestamp.c
17856Starting at line 681 of /home/shackle/pggit/postgresql/src/backend/utils/adt/varbit.c
17857
17858interval_transform(PG_FUNCTION_ARGS)
17859{
17860 FuncExpr *expr = castNode(FuncExpr, PG_GETARG_POINTER(0));
17861 Node *ret = NULL;
17862 Node *typmod;
17863
17864 Assert(list_length(expr->args) >= 2);
17865
17866 typmod = (Node *) lsecond(expr->args);
17867
17868 if (IsA(typmod, Const) &&!((Const *) typmod)->constisnull)
17869 {
17870 Node *source = (Node *) linitial(expr->args);
17871 int32 new_typmod = DatumGetInt32(((Const *) typmod)->constvalue);
17872=====================================================================
17873Found a 32 line (105 tokens) duplication in the following files:
17874Starting at line 4547 of /home/shackle/pggit/postgresql/src/backend/utils/adt/timestamp.c
17875Starting at line 4935 of /home/shackle/pggit/postgresql/src/backend/utils/adt/timestamp.c
17876
17877 switch (val)
17878 {
17879 case DTK_MICROSEC:
17880 result = tm->tm_sec * 1000000.0 + fsec;
17881 break;
17882
17883 case DTK_MILLISEC:
17884 result = tm->tm_sec * 1000.0 + fsec / 1000.0;
17885 break;
17886
17887 case DTK_SECOND:
17888 result = tm->tm_sec + fsec / 1000000.0;
17889 break;
17890
17891 case DTK_MINUTE:
17892 result = tm->tm_min;
17893 break;
17894
17895 case DTK_HOUR:
17896 result = tm->tm_hour;
17897 break;
17898
17899 case DTK_DAY:
17900 result = tm->tm_mday;
17901 break;
17902
17903 case DTK_MONTH:
17904 result = tm->tm_mon;
17905 break;
17906
17907 case DTK_QUARTER:
17908 result = (tm->tm_mon - 1) / 3 + 1;
17909=====================================================================
17910Found a 24 line (105 tokens) duplication in the following files:
17911Starting at line 3241 of /home/shackle/pggit/postgresql/src/backend/utils/adt/varlena.c
17912Starting at line 1695 of /home/shackle/pggit/postgresql/src/backend/utils/adt/regproc.c
17913
17914 rawname = text_to_cstring(textval);
17915
17916 if (!SplitIdentifierString(rawname, '.', &namelist))
17917 ereport(ERROR,
17918 (errcode(ERRCODE_INVALID_NAME),
17919 errmsg("invalid name syntax")));
17920
17921 if (namelist == NIL)
17922 ereport(ERROR,
17923 (errcode(ERRCODE_INVALID_NAME),
17924 errmsg("invalid name syntax")));
17925
17926 foreach(l, namelist)
17927 {
17928 char *curname = (char *) lfirst(l);
17929
17930 result = lappend(result, makeString(pstrdup(curname)));
17931 }
17932
17933 pfree(rawname);
17934 list_free(namelist);
17935
17936 return result;
17937}
17938=====================================================================
17939Found a 27 line (105 tokens) duplication in the following files:
17940Starting at line 847 of /home/shackle/pggit/postgresql/src/backend/access/heap/tuptoaster.c
17941Starting at line 961 of /home/shackle/pggit/postgresql/src/backend/access/heap/tuptoaster.c
17942
17943 if (att->attstorage != 'x' && att->attstorage != 'e')
17944 continue;
17945 if (toast_sizes[i] > biggest_size)
17946 {
17947 biggest_attno = i;
17948 biggest_size = toast_sizes[i];
17949 }
17950 }
17951
17952 if (biggest_attno < 0)
17953 break;
17954
17955 /*
17956 * Store this external
17957 */
17958 i = biggest_attno;
17959 old_value = toast_values[i];
17960 toast_action[i] = 'p';
17961 toast_values[i] = toast_save_datum(rel, toast_values[i],
17962 toast_oldexternal[i], options);
17963 if (toast_free[i])
17964 pfree(DatumGetPointer(old_value));
17965 toast_free[i] = true;
17966
17967 need_change = true;
17968 need_free = true;
17969 }
17970=====================================================================
17971Found a 17 line (104 tokens) duplication in the following files:
17972Starting at line 520 of /home/shackle/pggit/postgresql/contrib/ltree/_ltree_gist.c
17973Starting at line 582 of /home/shackle/pggit/postgresql/contrib/ltree/ltree_gist.c
17974
17975_arrq_cons(ltree_gist *key, ArrayType *_query)
17976{
17977 lquery *query = (lquery *) ARR_DATA_PTR(_query);
17978 int num = ArrayGetNItems(ARR_NDIM(_query), ARR_DIMS(_query));
17979
17980 if (ARR_NDIM(_query) > 1)
17981 ereport(ERROR,
17982 (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
17983 errmsg("array must be one-dimensional")));
17984 if (array_contains_nulls(_query))
17985 ereport(ERROR,
17986 (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
17987 errmsg("array must not contain nulls")));
17988
17989 while (num > 0)
17990 {
17991 if (gist_qe(key, query))
17992=====================================================================
17993Found a 20 line (104 tokens) duplication in the following files:
17994Starting at line 880 of /home/shackle/pggit/postgresql/contrib/pg_trgm/trgm_gist.c
17995Starting at line 222 of /home/shackle/pggit/postgresql/src/backend/utils/adt/tsquery_gist.c
17996
17997 size_beta = hemdistcache(&(cache[seed_2]), &(cache[j]));
17998 costvector[j - 1].cost = abs(size_alpha - size_beta);
17999 }
18000 qsort((void *) costvector, maxoff, sizeof(SPLITCOST), comparecost);
18001
18002 for (k = 0; k < maxoff; k++)
18003 {
18004 j = costvector[k].pos;
18005 if (j == seed_1)
18006 {
18007 *left++ = j;
18008 v->spl_nleft++;
18009 continue;
18010 }
18011 else if (j == seed_2)
18012 {
18013 *right++ = j;
18014 v->spl_nright++;
18015 continue;
18016 }
18017=====================================================================
18018Found a 24 line (104 tokens) duplication in the following files:
18019Starting at line 1174 of /home/shackle/pggit/postgresql/contrib/pgcrypto/imath.c
18020Starting at line 1212 of /home/shackle/pggit/postgresql/contrib/pgcrypto/imath.c
18021
18022 if ((res = mp_int_init_copy(&t, a)) != MP_OK)
18023 return res;
18024
18025 (void) mp_int_set_value(c, 1);
18026 while (v != 0)
18027 {
18028 if (v & 1)
18029 {
18030 if ((res = mp_int_mul(c, &t, c)) != MP_OK)
18031 goto CLEANUP;
18032 }
18033
18034 v >>= 1;
18035 if (v == 0)
18036 break;
18037
18038 if ((res = mp_int_sqr(&t, &t)) != MP_OK)
18039 goto CLEANUP;
18040 }
18041
18042CLEANUP:
18043 mp_int_clear(&t);
18044 return res;
18045}
18046=====================================================================
18047Found a 21 line (104 tokens) duplication in the following files:
18048Starting at line 82 of /home/shackle/pggit/postgresql/src/bin/scripts/vacuumdb.c
18049Starting at line 31 of /home/shackle/pggit/postgresql/src/bin/scripts/reindexdb.c
18050Starting at line 25 of /home/shackle/pggit/postgresql/src/bin/scripts/clusterdb.c
18051
18052static void init_slot(ParallelSlot *slot, PGconn *conn);
18053
18054static void help(const char *progname);
18055
18056/* For analyze-in-stages mode */
18057#define ANALYZE_NO_STAGE -1
18058#define ANALYZE_NUM_STAGES 3
18059
18060
18061int
18062main(int argc, char *argv[])
18063{
18064 static struct option long_options[] = {
18065 {"host", required_argument, NULL, 'h'},
18066 {"port", required_argument, NULL, 'p'},
18067 {"username", required_argument, NULL, 'U'},
18068 {"no-password", no_argument, NULL, 'w'},
18069 {"password", no_argument, NULL, 'W'},
18070 {"echo", no_argument, NULL, 'e'},
18071 {"quiet", no_argument, NULL, 'q'},
18072 {"dbname", required_argument, NULL, 'd'},
18073=====================================================================
18074Found a 23 line (104 tokens) duplication in the following files:
18075Starting at line 4646 of /home/shackle/pggit/postgresql/src/pl/plpgsql/src/pl_exec.c
18076Starting at line 4734 of /home/shackle/pggit/postgresql/src/pl/plpgsql/src/pl_exec.c
18077
18078 uint64 n;
18079 MemoryContext oldcontext;
18080
18081 /* ----------
18082 * Get the portal of the cursor by name
18083 * ----------
18084 */
18085 curvar = (PLpgSQL_var *) (estate->datums[stmt->curvar]);
18086 if (curvar->isnull)
18087 ereport(ERROR,
18088 (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
18089 errmsg("cursor variable \"%s\" is null", curvar->refname)));
18090
18091 /* Use eval_mcontext for short-lived string */
18092 oldcontext = MemoryContextSwitchTo(get_eval_mcontext(estate));
18093 curname = TextDatumGetCString(curvar->value);
18094 MemoryContextSwitchTo(oldcontext);
18095
18096 portal = SPI_cursor_find(curname);
18097 if (portal == NULL)
18098 ereport(ERROR,
18099 (errcode(ERRCODE_UNDEFINED_CURSOR),
18100 errmsg("cursor \"%s\" does not exist", curname)));
18101=====================================================================
18102Found a 29 line (104 tokens) duplication in the following files:
18103Starting at line 32 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/ecpglib/misc.c
18104Starting at line 21 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/compatlib/informix.c
18105
18106static struct sqlca_t sqlca_init =
18107{
18108 {
18109 'S', 'Q', 'L', 'C', 'A', ' ', ' ', ' '
18110 },
18111 sizeof(struct sqlca_t),
18112 0,
18113 {
18114 0,
18115 {
18116 0
18117 }
18118 },
18119 {
18120 'N', 'O', 'T', ' ', 'S', 'E', 'T', ' '
18121 },
18122 {
18123 0, 0, 0, 0, 0, 0
18124 },
18125 {
18126 0, 0, 0, 0, 0, 0, 0, 0
18127 },
18128 {
18129 '0', '0', '0', '0', '0'
18130 }
18131};
18132
18133#ifdef ENABLE_THREAD_SAFETY
18134static pthread_key_t sqlca_key;
18135=====================================================================
18136Found a 21 line (104 tokens) duplication in the following files:
18137Starting at line 114 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-oldexec.c
18138Starting at line 113 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-execute.c
18139
18140 { ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_execute, "i",
18141 ECPGt_int,&(increment),(long)1,(long)1,sizeof(int),
18142 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
18143#line 42 "oldexec.pgc"
18144
18145if (sqlca.sqlcode < 0) sqlprint();}
18146#line 42 "oldexec.pgc"
18147
18148
18149 printf("Inserted %ld tuples via prepared execute\n", sqlca.sqlerrd[2]);
18150
18151 { ECPGtrans(__LINE__, NULL, "commit");
18152#line 46 "oldexec.pgc"
18153
18154if (sqlca.sqlcode < 0) sqlprint();}
18155#line 46 "oldexec.pgc"
18156
18157
18158 sprintf (command, "select * from test");
18159
18160 { ECPGprepare(__LINE__, NULL, 1, "f", command);
18161=====================================================================
18162Found a 5 line (104 tokens) duplication in the following files:
18163Starting at line 98 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
18164Starting at line 103 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
18165
18166 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
18167 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
18168 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
18169 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
18170 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
18171=====================================================================
18172Found a 20 line (103 tokens) duplication in the following files:
18173Starting at line 1380 of /home/shackle/pggit/postgresql/contrib/hstore/hstore_io.c
18174Starting at line 1426 of /home/shackle/pggit/postgresql/contrib/hstore/hstore_io.c
18175
18176 JsonbValue *res;
18177
18178 (void) pushJsonbValue(&state, WJB_BEGIN_OBJECT, NULL);
18179
18180 for (i = 0; i < count; i++)
18181 {
18182 JsonbValue key,
18183 val;
18184
18185 key.type = jbvString;
18186 key.val.string.len = HSTORE_KEYLEN(entries, i);
18187 key.val.string.val = HSTORE_KEY(entries, base, i);
18188
18189 (void) pushJsonbValue(&state, WJB_KEY, &key);
18190
18191 if (HSTORE_VALISNULL(entries, i))
18192 {
18193 val.type = jbvNull;
18194 }
18195 else
18196=====================================================================
18197Found a 42 line (103 tokens) duplication in the following files:
18198Starting at line 3184 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-connect.c
18199Starting at line 3252 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-connect.c
18200
18201 return PGRES_POLLING_WRITING;
18202 }
18203
18204 /*
18205 * If a read-write connection is required, see if we have one.
18206 *
18207 * Servers before 7.4 lack the transaction_read_only GUC, but
18208 * by the same token they don't have any read-only mode, so we
18209 * may just skip the test in that case.
18210 */
18211 if (conn->sversion >= 70400 &&
18212 conn->target_session_attrs != NULL &&
18213 strcmp(conn->target_session_attrs, "read-write") == 0)
18214 {
18215 /*
18216 * Save existing error messages across the PQsendQuery
18217 * attempt. This is necessary because PQsendQuery is
18218 * going to reset conn->errorMessage, so we would lose
18219 * error messages related to previous hosts we have tried
18220 * and failed to connect to.
18221 */
18222 if (!saveErrorMessage(conn, &savedMessage))
18223 goto error_return;
18224
18225 conn->status = CONNECTION_OK;
18226 if (!PQsendQuery(conn,
18227 "SHOW transaction_read_only"))
18228 {
18229 restoreErrorMessage(conn, &savedMessage);
18230 goto error_return;
18231 }
18232 conn->status = CONNECTION_CHECK_WRITABLE;
18233 restoreErrorMessage(conn, &savedMessage);
18234 return PGRES_POLLING_READING;
18235 }
18236
18237 /* We can release the address list now. */
18238 release_conn_addrinfo(conn);
18239
18240 /* We are open for business! */
18241 conn->status = CONNECTION_OK;
18242 return PGRES_POLLING_OK;
18243=====================================================================
18244Found a 16 line (103 tokens) duplication in the following files:
18245Starting at line 1186 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
18246Starting at line 1490 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
18247
18248 InitFunctionCallInfoData(fcinfo, flinfo, 4, collation, NULL, NULL);
18249
18250 fcinfo.arg[0] = arg1;
18251 fcinfo.arg[1] = arg2;
18252 fcinfo.arg[2] = arg3;
18253 fcinfo.arg[3] = arg4;
18254 fcinfo.argnull[0] = false;
18255 fcinfo.argnull[1] = false;
18256 fcinfo.argnull[2] = false;
18257 fcinfo.argnull[3] = false;
18258
18259 result = FunctionCallInvoke(&fcinfo);
18260
18261 /* Check for null result, since caller is clearly not expecting one */
18262 if (fcinfo.isnull)
18263 elog(ERROR, "function %u returned NULL", fcinfo.flinfo->fn_oid);
18264=====================================================================
18265Found a 29 line (103 tokens) duplication in the following files:
18266Starting at line 773 of /home/shackle/pggit/postgresql/src/backend/utils/mmgr/mcxt.c
18267Starting at line 959 of /home/shackle/pggit/postgresql/src/backend/utils/mmgr/mcxt.c
18268
18269 void *ret;
18270
18271 AssertArg(MemoryContextIsValid(context));
18272 AssertNotInCriticalSection(context);
18273
18274 if (!AllocSizeIsValid(size))
18275 elog(ERROR, "invalid memory alloc request size %zu", size);
18276
18277 context->isReset = false;
18278
18279 ret = context->methods->alloc(context, size);
18280 if (unlikely(ret == NULL))
18281 {
18282 MemoryContextStats(TopMemoryContext);
18283
18284 /*
18285 * Here, and elsewhere in this module, we show the target context's
18286 * "name" but not its "ident" (if any) in user-visible error messages.
18287 * The "ident" string might contain security-sensitive data, such as
18288 * values in SQL commands.
18289 */
18290 ereport(ERROR,
18291 (errcode(ERRCODE_OUT_OF_MEMORY),
18292 errmsg("out of memory"),
18293 errdetail("Failed on request of size %zu in memory context \"%s\".",
18294 size, context->name)));
18295 }
18296
18297 VALGRIND_MEMPOOL_ALLOC(context, ret, size);
18298=====================================================================
18299Found a 22 line (103 tokens) duplication in the following files:
18300Starting at line 816 of /home/shackle/pggit/postgresql/src/backend/utils/mmgr/mcxt.c
18301Starting at line 854 of /home/shackle/pggit/postgresql/src/backend/utils/mmgr/mcxt.c
18302Starting at line 928 of /home/shackle/pggit/postgresql/src/backend/utils/mmgr/mcxt.c
18303
18304 void *ret;
18305
18306 AssertArg(MemoryContextIsValid(context));
18307 AssertNotInCriticalSection(context);
18308
18309 if (!AllocSizeIsValid(size))
18310 elog(ERROR, "invalid memory alloc request size %zu", size);
18311
18312 context->isReset = false;
18313
18314 ret = context->methods->alloc(context, size);
18315 if (unlikely(ret == NULL))
18316 {
18317 MemoryContextStats(TopMemoryContext);
18318 ereport(ERROR,
18319 (errcode(ERRCODE_OUT_OF_MEMORY),
18320 errmsg("out of memory"),
18321 errdetail("Failed on request of size %zu in memory context \"%s\".",
18322 size, context->name)));
18323 }
18324
18325 VALGRIND_MEMPOOL_ALLOC(context, ret, size);
18326=====================================================================
18327Found a 22 line (103 tokens) duplication in the following files:
18328Starting at line 102 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conv.c
18329Starting at line 249 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conv.c
18330
18331 int c1;
18332
18333 while (len > 0)
18334 {
18335 c1 = *mic;
18336 if (c1 == 0)
18337 report_invalid_encoding(PG_MULE_INTERNAL, (const char *) mic, len);
18338 if (!IS_HIGHBIT_SET(c1))
18339 {
18340 /* easy for ASCII */
18341 *p++ = c1;
18342 mic++;
18343 len--;
18344 }
18345 else
18346 {
18347 int l = pg_mic_mblen(mic);
18348
18349 if (len < l)
18350 report_invalid_encoding(PG_MULE_INTERNAL, (const char *) mic,
18351 len);
18352 if (l != 2 || c1 != lc || !IS_HIGHBIT_SET(mic[1]))
18353=====================================================================
18354Found a 16 line (103 tokens) duplication in the following files:
18355Starting at line 3590 of /home/shackle/pggit/postgresql/src/backend/utils/adt/formatting.c
18356Starting at line 3622 of /home/shackle/pggit/postgresql/src/backend/utils/adt/formatting.c
18357
18358 if (timestamp2tm(dt, NULL, tm, &tmtcFsec(&tmtc), NULL, NULL) != 0)
18359 ereport(ERROR,
18360 (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
18361 errmsg("timestamp out of range")));
18362
18363 thisdate = date2j(tm->tm_year, tm->tm_mon, tm->tm_mday);
18364 tm->tm_wday = (thisdate + 1) % 7;
18365 tm->tm_yday = thisdate - date2j(tm->tm_year, 1, 1) + 1;
18366
18367 if (!(res = datetime_to_char_body(&tmtc, fmt, false, PG_GET_COLLATION())))
18368 PG_RETURN_NULL();
18369
18370 PG_RETURN_TEXT_P(res);
18371}
18372
18373Datum
18374=====================================================================
18375Found a 22 line (103 tokens) duplication in the following files:
18376Starting at line 4194 of /home/shackle/pggit/postgresql/src/backend/utils/adt/numeric.c
18377Starting at line 4425 of /home/shackle/pggit/postgresql/src/backend/utils/adt/numeric.c
18378
18379numeric_poly_combine(PG_FUNCTION_ARGS)
18380{
18381 PolyNumAggState *state1;
18382 PolyNumAggState *state2;
18383 MemoryContext agg_context;
18384 MemoryContext old_context;
18385
18386 if (!AggCheckCallContext(fcinfo, &agg_context))
18387 elog(ERROR, "aggregate function called in non-aggregate context");
18388
18389 state1 = PG_ARGISNULL(0) ? NULL : (PolyNumAggState *) PG_GETARG_POINTER(0);
18390 state2 = PG_ARGISNULL(1) ? NULL : (PolyNumAggState *) PG_GETARG_POINTER(1);
18391
18392 if (state2 == NULL)
18393 PG_RETURN_POINTER(state1);
18394
18395 /* manually copy all fields from state2 to state1 */
18396 if (state1 == NULL)
18397 {
18398 old_context = MemoryContextSwitchTo(agg_context);
18399
18400 state1 = makePolyNumAggState(fcinfo, true);
18401=====================================================================
18402Found a 31 line (103 tokens) duplication in the following files:
18403Starting at line 2935 of /home/shackle/pggit/postgresql/src/backend/utils/adt/float.c
18404Starting at line 3073 of /home/shackle/pggit/postgresql/src/backend/utils/adt/float.c
18405
18406 PG_RETURN_ARRAYTYPE_P(transarray);
18407 }
18408 else
18409 {
18410 Datum transdatums[6];
18411 ArrayType *result;
18412
18413 transdatums[0] = Float8GetDatumFast(N);
18414 transdatums[1] = Float8GetDatumFast(Sx);
18415 transdatums[2] = Float8GetDatumFast(Sxx);
18416 transdatums[3] = Float8GetDatumFast(Sy);
18417 transdatums[4] = Float8GetDatumFast(Syy);
18418 transdatums[5] = Float8GetDatumFast(Sxy);
18419
18420 result = construct_array(transdatums, 6,
18421 FLOAT8OID,
18422 sizeof(float8), FLOAT8PASSBYVAL, 'd');
18423
18424 PG_RETURN_ARRAYTYPE_P(result);
18425 }
18426}
18427
18428/*
18429 * float8_regr_combine
18430 *
18431 * An aggregate combine function used to combine two 6 fields
18432 * aggregate transition data into a single transition data.
18433 * This function is used only in two stage aggregation and
18434 * shouldn't be called outside aggregate context.
18435 */
18436Datum
18437=====================================================================
18438Found a 21 line (103 tokens) duplication in the following files:
18439Starting at line 824 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rangetypes.c
18440Starting at line 911 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rangetypes.c
18441
18442range_overlaps_internal(TypeCacheEntry *typcache, RangeType *r1, RangeType *r2)
18443{
18444 RangeBound lower1,
18445 lower2;
18446 RangeBound upper1,
18447 upper2;
18448 bool empty1,
18449 empty2;
18450
18451 /* Different types should be prevented by ANYRANGE matching rules */
18452 if (RangeTypeGetOid(r1) != RangeTypeGetOid(r2))
18453 elog(ERROR, "range types do not match");
18454
18455 range_deserialize(typcache, r1, &lower1, &upper1, &empty1);
18456 range_deserialize(typcache, r2, &lower2, &upper2, &empty2);
18457
18458 /* An empty range does not overlap any other range */
18459 if (empty1 || empty2)
18460 return false;
18461
18462 if (range_cmp_bounds(typcache, &lower1, &lower2) >= 0 &&
18463=====================================================================
18464Found a 22 line (103 tokens) duplication in the following files:
18465Starting at line 421 of /home/shackle/pggit/postgresql/src/backend/utils/adt/geo_ops.c
18466Starting at line 466 of /home/shackle/pggit/postgresql/src/backend/utils/adt/geo_ops.c
18467
18468 path_decode(str, false, 2, &(box->high), &isopen, NULL, "box", str);
18469
18470 /* reorder corners if necessary... */
18471 if (float8_lt(box->high.x, box->low.x))
18472 {
18473 x = box->high.x;
18474 box->high.x = box->low.x;
18475 box->low.x = x;
18476 }
18477 if (float8_lt(box->high.y, box->low.y))
18478 {
18479 y = box->high.y;
18480 box->high.y = box->low.y;
18481 box->low.y = y;
18482 }
18483
18484 PG_RETURN_BOX_P(box);
18485}
18486
18487/* box_out - convert a box to external form.
18488 */
18489Datum
18490=====================================================================
18491Found a 15 line (103 tokens) duplication in the following files:
18492Starting at line 10675 of /home/shackle/pggit/postgresql/src/backend/commands/tablecmds.c
18493Starting at line 10732 of /home/shackle/pggit/postgresql/src/backend/commands/tablecmds.c
18494
18495 memset(repl_val, 0, sizeof(repl_val));
18496 memset(repl_null, false, sizeof(repl_null));
18497 memset(repl_repl, false, sizeof(repl_repl));
18498
18499 if (newOptions != (Datum) 0)
18500 repl_val[Anum_pg_class_reloptions - 1] = newOptions;
18501 else
18502 repl_null[Anum_pg_class_reloptions - 1] = true;
18503
18504 repl_repl[Anum_pg_class_reloptions - 1] = true;
18505
18506 newtuple = heap_modify_tuple(tuple, RelationGetDescr(pgclass),
18507 repl_val, repl_null, repl_repl);
18508
18509 CatalogTupleUpdate(pgclass, &newtuple->t_self, newtuple);
18510=====================================================================
18511Found a 24 line (102 tokens) duplication in the following files:
18512Starting at line 17 of /home/shackle/pggit/postgresql/contrib/hstore_plpython/hstore_plpython.c
18513Starting at line 12 of /home/shackle/pggit/postgresql/contrib/hstore_plperl/hstore_plperl.c
18514
18515static PLyUnicode_FromStringAndSize_t PLyUnicode_FromStringAndSize_p;
18516#endif
18517
18518/* Linkage to functions in hstore module */
18519typedef HStore *(*hstoreUpgrade_t) (Datum orig);
18520static hstoreUpgrade_t hstoreUpgrade_p;
18521typedef int (*hstoreUniquePairs_t) (Pairs *a, int32 l, int32 *buflen);
18522static hstoreUniquePairs_t hstoreUniquePairs_p;
18523typedef HStore *(*hstorePairs_t) (Pairs *pairs, int32 pcount, int32 buflen);
18524static hstorePairs_t hstorePairs_p;
18525typedef size_t (*hstoreCheckKeyLen_t) (size_t len);
18526static hstoreCheckKeyLen_t hstoreCheckKeyLen_p;
18527typedef size_t (*hstoreCheckValLen_t) (size_t len);
18528static hstoreCheckValLen_t hstoreCheckValLen_p;
18529
18530
18531/*
18532 * Module initialize function: fetch function pointers for cross-module calls.
18533 */
18534void
18535_PG_init(void)
18536{
18537 /* Asserts verify that typedefs above match original declarations */
18538 AssertVariableIsOfType(&PLyObject_AsString, PLyObject_AsString_t);
18539=====================================================================
18540Found a 21 line (102 tokens) duplication in the following files:
18541Starting at line 287 of /home/shackle/pggit/postgresql/contrib/hstore/hstore_gist.c
18542Starting at line 280 of /home/shackle/pggit/postgresql/contrib/intarray/_intbig_gist.c
18543
18544 for (i = 0; i < len; i++)
18545 {
18546 if (unionkey(base, GETENTRY(entryvec, i)))
18547 {
18548 flag = ALLISTRUE;
18549 break;
18550 }
18551 }
18552
18553 len = CALCGTSIZE(flag);
18554 result = (GISTTYPE *) palloc(len);
18555 SET_VARSIZE(result, len);
18556 result->flag = flag;
18557 if (!ISALLTRUE(result))
18558 memcpy((void *) GETSIGN(result), (void *) base, sizeof(BITVEC));
18559 *size = len;
18560
18561 PG_RETURN_POINTER(result);
18562}
18563
18564Datum
18565=====================================================================
18566Found a 24 line (102 tokens) duplication in the following files:
18567Starting at line 477 of /home/shackle/pggit/postgresql/contrib/ltree/_ltree_gist.c
18568Starting at line 476 of /home/shackle/pggit/postgresql/contrib/ltree/ltree_gist.c
18569
18570 );
18571}
18572
18573static bool
18574gist_qe(ltree_gist *key, lquery *query)
18575{
18576 lquery_level *curq = LQUERY_FIRST(query);
18577 BITVECP sign = LTG_SIGN(key);
18578 int qlen = query->numlevel;
18579
18580 if (LTG_ISALLTRUE(key))
18581 return true;
18582
18583 while (qlen > 0)
18584 {
18585 if (curq->numvar && LQL_CANLOOKSIGN(curq))
18586 {
18587 bool isexist = false;
18588 int vlen = curq->numvar;
18589 lquery_variant *curv = LQL_FIRST(curq);
18590
18591 while (vlen > 0)
18592 {
18593 if (GETBIT(sign, AHASHVAL(curv->val)))
18594=====================================================================
18595Found a 29 line (102 tokens) duplication in the following files:
18596Starting at line 143 of /home/shackle/pggit/postgresql/src/bin/scripts/vacuumdb.c
18597Starting at line 70 of /home/shackle/pggit/postgresql/src/bin/scripts/clusterdb.c
18598
18599 while ((c = getopt_long(argc, argv, "h:p:U:wWeqd:zZFat:fvj:", long_options, &optindex)) != -1)
18600 {
18601 switch (c)
18602 {
18603 case 'h':
18604 host = pg_strdup(optarg);
18605 break;
18606 case 'p':
18607 port = pg_strdup(optarg);
18608 break;
18609 case 'U':
18610 username = pg_strdup(optarg);
18611 break;
18612 case 'w':
18613 prompt_password = TRI_NO;
18614 break;
18615 case 'W':
18616 prompt_password = TRI_YES;
18617 break;
18618 case 'e':
18619 echo = true;
18620 break;
18621 case 'q':
18622 quiet = true;
18623 break;
18624 case 'd':
18625 dbname = pg_strdup(optarg);
18626 break;
18627 case 'z':
18628=====================================================================
18629Found a 36 line (102 tokens) duplication in the following files:
18630Starting at line 4171 of /home/shackle/pggit/postgresql/src/pl/plpgsql/src/pl_exec.c
18631Starting at line 4361 of /home/shackle/pggit/postgresql/src/pl/plpgsql/src/pl_exec.c
18632
18633 expr->query, SPI_result_code_string(rc));
18634 break;
18635 }
18636
18637 /* All variants should save result info for GET DIAGNOSTICS */
18638 estate->eval_processed = SPI_processed;
18639
18640 /* Process INTO if present */
18641 if (stmt->into)
18642 {
18643 SPITupleTable *tuptab = SPI_tuptable;
18644 uint64 n = SPI_processed;
18645 PLpgSQL_variable *target;
18646
18647 /* If the statement did not return a tuple table, complain */
18648 if (tuptab == NULL)
18649 ereport(ERROR,
18650 (errcode(ERRCODE_SYNTAX_ERROR),
18651 errmsg("INTO used with a command that cannot return data")));
18652
18653 /* Fetch target's datum entry */
18654 target = (PLpgSQL_variable *) estate->datums[stmt->target->dno];
18655
18656 /*
18657 * If SELECT ... INTO specified STRICT, and the query didn't find
18658 * exactly one row, throw an error. If STRICT was not specified, then
18659 * allow the query to find any number of rows.
18660 */
18661 if (n == 0)
18662 {
18663 if (stmt->strict)
18664 {
18665 char *errdetail;
18666
18667 if (estate->func->print_strict_params)
18668 errdetail = format_expr_params(estate, expr);
18669=====================================================================
18670Found a 31 line (102 tokens) duplication in the following files:
18671Starting at line 2294 of /home/shackle/pggit/postgresql/src/pl/plperl/plperl.c
18672Starting at line 2357 of /home/shackle/pggit/postgresql/src/pl/plperl/plperl.c
18673
18674 PUSHs(sv_2mortal(cstr2sv(tg_trigger->tgargs[i])));
18675 PUTBACK;
18676
18677 /* Do NOT use G_KEEPERR here */
18678 count = perl_call_sv(desc->reference, G_SCALAR | G_EVAL);
18679
18680 SPAGAIN;
18681
18682 if (count != 1)
18683 {
18684 PUTBACK;
18685 FREETMPS;
18686 LEAVE;
18687 ereport(ERROR,
18688 (errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
18689 errmsg("didn't get a return item from trigger function")));
18690 }
18691
18692 if (SvTRUE(ERRSV))
18693 {
18694 (void) POPs;
18695 PUTBACK;
18696 FREETMPS;
18697 LEAVE;
18698 /* XXX need to find a way to determine a better errcode here */
18699 ereport(ERROR,
18700 (errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
18701 errmsg("%s", strip_trailing_ws(sv2cstr(ERRSV)))));
18702 }
18703
18704 retval = newSVsv(POPs);
18705=====================================================================
18706Found a 36 line (102 tokens) duplication in the following files:
18707Starting at line 3410 of /home/shackle/pggit/postgresql/src/pl/plperl/plperl.c
18708Starting at line 3893 of /home/shackle/pggit/postgresql/src/pl/plperl/plperl.c
18709
18710 if (portal == NULL)
18711 elog(ERROR, "SPI_cursor_open() failed:%s",
18712 SPI_result_code_string(SPI_result));
18713 cursor = cstr2sv(portal->name);
18714
18715 PinPortal(portal);
18716
18717 /* Commit the inner transaction, return to outer xact context */
18718 ReleaseCurrentSubTransaction();
18719 MemoryContextSwitchTo(oldcontext);
18720 CurrentResourceOwner = oldowner;
18721 }
18722 PG_CATCH();
18723 {
18724 ErrorData *edata;
18725
18726 /* Save error info */
18727 MemoryContextSwitchTo(oldcontext);
18728 edata = CopyErrorData();
18729 FlushErrorState();
18730
18731 /* Abort the inner transaction */
18732 RollbackAndReleaseCurrentSubTransaction();
18733 MemoryContextSwitchTo(oldcontext);
18734 CurrentResourceOwner = oldowner;
18735
18736 /* Punt the error to Perl */
18737 croak_cstr(edata->message);
18738
18739 /* Can't get here, but keep compiler quiet */
18740 return NULL;
18741 }
18742 PG_END_TRY();
18743
18744 return cursor;
18745}
18746=====================================================================
18747Found a 4 line (102 tokens) duplication in the following files:
18748Starting at line 30 of /home/shackle/pggit/postgresql/src/common/base64.c
18749Starting at line 3562 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
18750Starting at line 888 of /home/shackle/pggit/postgresql/src/backend/utils/adt/formatting.c
18751Starting at line 114 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
18752Starting at line 206 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
18753Starting at line 40 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
18754
18755static const int8 b64lookup[128] = {
18756 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
18757 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
18758 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
18759=====================================================================
18760Found a 3 line (102 tokens) duplication in the following files:
18761Starting at line 31 of /home/shackle/pggit/postgresql/src/common/base64.c
18762Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
18763Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
18764Starting at line 207 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
18765Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
18766
18767 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
18768 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
18769 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
18770=====================================================================
18771Found a 3 line (102 tokens) duplication in the following files:
18772Starting at line 31 of /home/shackle/pggit/postgresql/src/common/base64.c
18773Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
18774Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
18775Starting at line 207 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
18776Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
18777
18778 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
18779 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
18780 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
18781=====================================================================
18782Found a 26 line (102 tokens) duplication in the following files:
18783Starting at line 599 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/numeric.c
18784Starting at line 687 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/numeric.c
18785
18786 carry = 0;
18787 }
18788 }
18789
18790 while (res_ndigits > 0 && *res_digits == 0)
18791 {
18792 res_digits++;
18793 res_weight--;
18794 res_ndigits--;
18795 }
18796 while (res_ndigits > 0 && res_digits[res_ndigits - 1] == 0)
18797 res_ndigits--;
18798
18799 if (res_ndigits == 0)
18800 res_weight = 0;
18801
18802 digitbuf_free(result->buf);
18803 result->ndigits = res_ndigits;
18804 result->buf = res_buf;
18805 result->digits = res_digits;
18806 result->weight = res_weight;
18807 result->rscale = res_rscale;
18808 result->dscale = res_dscale;
18809
18810 return 0;
18811}
18812=====================================================================
18813Found a 5 line (102 tokens) duplication in the following files:
18814Starting at line 98 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
18815Starting at line 103 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
18816
18817 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
18818 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
18819 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
18820 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
18821 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
18822=====================================================================
18823Found a 14 line (102 tokens) duplication in the following files:
18824Starting at line 893 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
18825Starting at line 1213 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
18826Starting at line 1520 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
18827
18828 InitFunctionCallInfoData(fcinfo, NULL, 5, collation, NULL, NULL);
18829
18830 fcinfo.arg[0] = arg1;
18831 fcinfo.arg[1] = arg2;
18832 fcinfo.arg[2] = arg3;
18833 fcinfo.arg[3] = arg4;
18834 fcinfo.arg[4] = arg5;
18835 fcinfo.argnull[0] = false;
18836 fcinfo.argnull[1] = false;
18837 fcinfo.argnull[2] = false;
18838 fcinfo.argnull[3] = false;
18839 fcinfo.argnull[4] = false;
18840
18841 result = (*func) (&fcinfo);
18842=====================================================================
18843Found a 23 line (102 tokens) duplication in the following files:
18844Starting at line 171 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c
18845Starting at line 598 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c
18846
18847 c2 = sjis[1];
18848 k = (c1 << 8) + c2;
18849 if (k >= 0xed40 && k < 0xf040)
18850 {
18851 /* NEC selection IBM kanji */
18852 for (i = 0;; i++)
18853 {
18854 k2 = ibmkanji[i].nec;
18855 if (k2 == 0xffff)
18856 break;
18857 if (k2 == k)
18858 {
18859 k = ibmkanji[i].sjis;
18860 c1 = (k >> 8) & 0xff;
18861 c2 = k & 0xff;
18862 }
18863 }
18864 }
18865
18866 if (k < 0xeb3f)
18867 {
18868 /* JIS X0208 */
18869 *p++ = LC_JISX0208;
18870=====================================================================
18871Found a 61 line (102 tokens) duplication in the following files:
18872Starting at line 6674 of /home/shackle/pggit/postgresql/src/backend/utils/adt/numeric.c
18873Starting at line 6795 of /home/shackle/pggit/postgresql/src/backend/utils/adt/numeric.c
18874
18875 if (var2->sign == NUMERIC_POS)
18876 {
18877 /* ----------
18878 * var1 is negative, var2 is positive
18879 * Must compare absolute values
18880 * ----------
18881 */
18882 switch (cmp_abs(var1, var2))
18883 {
18884 case 0:
18885 /* ----------
18886 * ABS(var1) == ABS(var2)
18887 * result = ZERO
18888 * ----------
18889 */
18890 zero_var(result);
18891 result->dscale = Max(var1->dscale, var2->dscale);
18892 break;
18893
18894 case 1:
18895 /* ----------
18896 * ABS(var1) > ABS(var2)
18897 * result = -(ABS(var1) - ABS(var2))
18898 * ----------
18899 */
18900 sub_abs(var1, var2, result);
18901 result->sign = NUMERIC_NEG;
18902 break;
18903
18904 case -1:
18905 /* ----------
18906 * ABS(var1) < ABS(var2)
18907 * result = +(ABS(var2) - ABS(var1))
18908 * ----------
18909 */
18910 sub_abs(var2, var1, result);
18911 result->sign = NUMERIC_POS;
18912 break;
18913 }
18914 }
18915 else
18916 {
18917 /* ----------
18918 * Both are negative
18919 * result = -(ABS(var1) + ABS(var2))
18920 * ----------
18921 */
18922 add_abs(var1, var2, result);
18923 result->sign = NUMERIC_NEG;
18924 }
18925 }
18926}
18927
18928
18929/*
18930 * sub_var() -
18931 *
18932 * Full version of sub functionality on variable level (handling signs).
18933 * result might point to one of the operands too without danger.
18934 */
18935static void
18936=====================================================================
18937Found a 24 line (102 tokens) duplication in the following files:
18938Starting at line 323 of /home/shackle/pggit/postgresql/src/backend/utils/adt/varbit.c
18939Starting at line 638 of /home/shackle/pggit/postgresql/src/backend/utils/adt/varbit.c
18940
18941 bitlen, atttypmod)));
18942
18943 len = VARBITTOTALLEN(bitlen);
18944 result = (VarBit *) palloc(len);
18945 SET_VARSIZE(result, len);
18946 VARBITLEN(result) = bitlen;
18947
18948 pq_copymsgbytes(buf, (char *) VARBITS(result), VARBITBYTES(result));
18949
18950 /* Make sure last byte is zero-padded if needed */
18951 ipad = VARBITPAD(result);
18952 if (ipad > 0)
18953 {
18954 mask = BITMASK << ipad;
18955 *(VARBITS(result) + VARBITBYTES(result) - 1) &= mask;
18956 }
18957
18958 PG_RETURN_VARBIT_P(result);
18959}
18960
18961/*
18962 * bit_send - converts bit to binary format
18963 */
18964Datum
18965=====================================================================
18966Found a 20 line (102 tokens) duplication in the following files:
18967Starting at line 1394 of /home/shackle/pggit/postgresql/src/backend/utils/adt/varbit.c
18968Starting at line 1459 of /home/shackle/pggit/postgresql/src/backend/utils/adt/varbit.c
18969
18970 PG_RETURN_DATUM(DirectFunctionCall2(bitshiftright,
18971 VarBitPGetDatum(arg),
18972 Int32GetDatum(-shft)));
18973 }
18974
18975 result = (VarBit *) palloc(VARSIZE(arg));
18976 SET_VARSIZE(result, VARSIZE(arg));
18977 VARBITLEN(result) = VARBITLEN(arg);
18978 r = VARBITS(result);
18979
18980 /* If we shifted all the bits out, return an all-zero string */
18981 if (shft >= VARBITLEN(arg))
18982 {
18983 MemSet(r, 0, VARBITBYTES(arg));
18984 PG_RETURN_VARBIT_P(result);
18985 }
18986
18987 byte_shift = shft / BITS_PER_BYTE;
18988 ishift = shft % BITS_PER_BYTE;
18989 p = VARBITS(arg) + byte_shift;
18990=====================================================================
18991Found a 20 line (101 tokens) duplication in the following files:
18992Starting at line 113 of /home/shackle/pggit/postgresql/src/port/qsort.c
18993Starting at line 113 of /home/shackle/pggit/postgresql/src/port/qsort_arg.c
18994
18995pg_qsort(void *a, size_t n, size_t es, int (*cmp) (const void *, const void *))
18996{
18997 char *pa,
18998 *pb,
18999 *pc,
19000 *pd,
19001 *pl,
19002 *pm,
19003 *pn;
19004 size_t d1,
19005 d2;
19006 int r,
19007 swaptype,
19008 presorted;
19009
19010loop:SWAPINIT(a, es);
19011 if (n < 7)
19012 {
19013 for (pm = (char *) a + es; pm < (char *) a + n * es; pm += es)
19014 for (pl = pm; pl > (char *) a && cmp(pl - es, pl) > 0;
19015=====================================================================
19016Found a 18 line (101 tokens) duplication in the following files:
19017Starting at line 140 of /home/shackle/pggit/postgresql/src/port/qsort.c
19018Starting at line 140 of /home/shackle/pggit/postgresql/src/port/qsort_arg.c
19019
19020 if (cmp(pm - es, pm) > 0)
19021 {
19022 presorted = 0;
19023 break;
19024 }
19025 }
19026 if (presorted)
19027 return;
19028 pm = (char *) a + (n / 2) * es;
19029 if (n > 7)
19030 {
19031 pl = (char *) a;
19032 pn = (char *) a + (n - 1) * es;
19033 if (n > 40)
19034 {
19035 size_t d = (n / 8) * es;
19036
19037 pl = med3(pl, pl + d, pl + 2 * d, cmp);
19038=====================================================================
19039Found a 21 line (101 tokens) duplication in the following files:
19040Starting at line 427 of /home/shackle/pggit/postgresql/src/bin/pg_basebackup/streamutil.c
19041Starting at line 489 of /home/shackle/pggit/postgresql/src/bin/pg_basebackup/receivelog.c
19042
19043 res = PQexec(conn, "IDENTIFY_SYSTEM");
19044 if (PQresultStatus(res) != PGRES_TUPLES_OK)
19045 {
19046 fprintf(stderr, _("%s: could not send replication command \"%s\": %s"),
19047 progname, "IDENTIFY_SYSTEM", PQerrorMessage(conn));
19048
19049 PQclear(res);
19050 return false;
19051 }
19052 if (PQntuples(res) != 1 || PQnfields(res) < 3)
19053 {
19054 fprintf(stderr,
19055 _("%s: could not identify system: got %d rows and %d fields, expected %d rows and %d or more fields\n"),
19056 progname, PQntuples(res), PQnfields(res), 1, 3);
19057
19058 PQclear(res);
19059 return false;
19060 }
19061
19062 /* Get system identifier */
19063 if (sysid != NULL)
19064=====================================================================
19065Found a 31 line (101 tokens) duplication in the following files:
19066Starting at line 296 of /home/shackle/pggit/postgresql/src/include/catalog/pg_type.h
19067Starting at line 191 of /home/shackle/pggit/postgresql/src/backend/catalog/pg_type.c
19068
19069extern ObjectAddress TypeCreate(Oid newTypeOid,
19070 const char *typeName,
19071 Oid typeNamespace,
19072 Oid relationOid,
19073 char relationKind,
19074 Oid ownerId,
19075 int16 internalSize,
19076 char typeType,
19077 char typeCategory,
19078 bool typePreferred,
19079 char typDelim,
19080 Oid inputProcedure,
19081 Oid outputProcedure,
19082 Oid receiveProcedure,
19083 Oid sendProcedure,
19084 Oid typmodinProcedure,
19085 Oid typmodoutProcedure,
19086 Oid analyzeProcedure,
19087 Oid elementType,
19088 bool isImplicitArray,
19089 Oid arrayType,
19090 Oid baseType,
19091 const char *defaultTypeValue,
19092 char *defaultTypeBin,
19093 bool passedByValue,
19094 char alignment,
19095 char storage,
19096 int32 typeMod,
19097 int32 typNDims,
19098 bool typeNotNull,
19099 Oid typeCollation);
19100=====================================================================
19101Found a 20 line (101 tokens) duplication in the following files:
19102Starting at line 113 of /home/shackle/pggit/postgresql/src/pl/plpython/plpy_resultobject.c
19103Starting at line 139 of /home/shackle/pggit/postgresql/src/pl/plpython/plpy_resultobject.c
19104Starting at line 165 of /home/shackle/pggit/postgresql/src/pl/plpython/plpy_resultobject.c
19105
19106PLy_result_colnames(PyObject *self, PyObject *unused)
19107{
19108 PLyResultObject *ob = (PLyResultObject *) self;
19109 PyObject *list;
19110 int i;
19111
19112 if (!ob->tupdesc)
19113 {
19114 PLy_exception_set(PLy_exc_error, "command did not produce a result set");
19115 return NULL;
19116 }
19117
19118 list = PyList_New(ob->tupdesc->natts);
19119 if (!list)
19120 return NULL;
19121 for (i = 0; i < ob->tupdesc->natts; i++)
19122 {
19123 Form_pg_attribute attr = TupleDescAttr(ob->tupdesc, i);
19124
19125 PyList_SET_ITEM(list, i, PyString_FromString(NameStr(attr->attname)));
19126=====================================================================
19127Found a 11 line (101 tokens) duplication in the following files:
19128Starting at line 193 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-oldexec.c
19129Starting at line 208 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-execute.c
19130
19131 { ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "declare CUR3 cursor for $1",
19132 ECPGt_char_variable,(ECPGprepared_statement(NULL, "f", __LINE__)),(long)1,(long)1,(1)*sizeof(char),
19133 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
19134 ECPGt_const,"1",(long)1,(long)1,strlen("1"),
19135 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
19136#line 72 "oldexec.pgc"
19137
19138if (sqlca.sqlcode < 0) sqlprint();}
19139#line 72 "oldexec.pgc"
19140
19141 { ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "fetch in CUR3", ECPGt_EOIT,
19142=====================================================================
19143Found a 17 line (101 tokens) duplication in the following files:
19144Starting at line 5412 of /home/shackle/pggit/postgresql/src/backend/optimizer/plan/createplan.c
19145Starting at line 6387 of /home/shackle/pggit/postgresql/src/backend/optimizer/plan/createplan.c
19146
19147 ListCell *slitem;
19148
19149 dupColIdx = (AttrNumber *) palloc(sizeof(AttrNumber) * numCols);
19150 dupOperators = (Oid *) palloc(sizeof(Oid) * numCols);
19151
19152 foreach(slitem, distinctList)
19153 {
19154 SortGroupClause *sortcl = (SortGroupClause *) lfirst(slitem);
19155 TargetEntry *tle = get_sortgroupclause_tle(sortcl,
19156 plan->targetlist);
19157
19158 dupColIdx[keyno] = tle->resno;
19159 dupOperators[keyno] = sortcl->eqop;
19160 Assert(OidIsValid(dupOperators[keyno]));
19161 keyno++;
19162 }
19163 node->dupColIdx = dupColIdx;
19164=====================================================================
19165Found a 24 line (101 tokens) duplication in the following files:
19166Starting at line 678 of /home/shackle/pggit/postgresql/src/backend/storage/lmgr/deadlock.c
19167Starting at line 751 of /home/shackle/pggit/postgresql/src/backend/storage/lmgr/deadlock.c
19168
19169 if ((LOCKBIT_ON(proc->waitLockMode) & conflictMask) != 0)
19170 {
19171 /* This proc soft-blocks checkProc */
19172 if (FindLockCycleRecurse(proc, depth + 1,
19173 softEdges, nSoftEdges))
19174 {
19175 /* fill deadlockDetails[] */
19176 DEADLOCK_INFO *info = &deadlockDetails[depth];
19177
19178 info->locktag = lock->tag;
19179 info->lockmode = checkProc->waitLockMode;
19180 info->pid = checkProc->pid;
19181
19182 /*
19183 * Add this edge to the list of soft edges in the cycle
19184 */
19185 Assert(*nSoftEdges < MaxBackends);
19186 softEdges[*nSoftEdges].waiter = checkProcLeader;
19187 softEdges[*nSoftEdges].blocker = leader;
19188 softEdges[*nSoftEdges].lock = lock;
19189 (*nSoftEdges)++;
19190 return true;
19191 }
19192 }
19193=====================================================================
19194Found a 22 line (101 tokens) duplication in the following files:
19195Starting at line 1220 of /home/shackle/pggit/postgresql/src/backend/catalog/pg_constraint.c
19196Starting at line 1281 of /home/shackle/pggit/postgresql/src/backend/catalog/pg_constraint.c
19197
19198 Oid conOid = InvalidOid;
19199
19200 pg_constraint = heap_open(ConstraintRelationId, AccessShareLock);
19201
19202 ScanKeyInit(&skey[0],
19203 Anum_pg_constraint_conrelid,
19204 BTEqualStrategyNumber, F_OIDEQ,
19205 ObjectIdGetDatum(relid));
19206 ScanKeyInit(&skey[1],
19207 Anum_pg_constraint_contypid,
19208 BTEqualStrategyNumber, F_OIDEQ,
19209 ObjectIdGetDatum(InvalidOid));
19210 ScanKeyInit(&skey[2],
19211 Anum_pg_constraint_conname,
19212 BTEqualStrategyNumber, F_NAMEEQ,
19213 CStringGetDatum(conname));
19214
19215 scan = systable_beginscan(pg_constraint, ConstraintRelidTypidNameIndexId, true,
19216 NULL, 3, skey);
19217
19218 /* There can be at most one matching row */
19219 if (HeapTupleIsValid(tuple = systable_getnext(scan)))
19220=====================================================================
19221Found a 24 line (101 tokens) duplication in the following files:
19222Starting at line 192 of /home/shackle/pggit/postgresql/src/backend/catalog/pg_depend.c
19223Starting at line 242 of /home/shackle/pggit/postgresql/src/backend/catalog/pg_depend.c
19224
19225 bool skipExtensionDeps)
19226{
19227 long count = 0;
19228 Relation depRel;
19229 ScanKeyData key[2];
19230 SysScanDesc scan;
19231 HeapTuple tup;
19232
19233 depRel = heap_open(DependRelationId, RowExclusiveLock);
19234
19235 ScanKeyInit(&key[0],
19236 Anum_pg_depend_classid,
19237 BTEqualStrategyNumber, F_OIDEQ,
19238 ObjectIdGetDatum(classId));
19239 ScanKeyInit(&key[1],
19240 Anum_pg_depend_objid,
19241 BTEqualStrategyNumber, F_OIDEQ,
19242 ObjectIdGetDatum(objectId));
19243
19244 scan = systable_beginscan(depRel, DependDependerIndexId, true,
19245 NULL, 2, key);
19246
19247 while (HeapTupleIsValid(tup = systable_getnext(scan)))
19248 {
19249=====================================================================
19250Found a 22 line (101 tokens) duplication in the following files:
19251Starting at line 199 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/euc_tw_and_big5.c
19252Starting at line 307 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/euc_tw_and_big5.c
19253
19254 int c1;
19255 int l;
19256
19257 while (len > 0)
19258 {
19259 c1 = *mic;
19260 if (!IS_HIGHBIT_SET(c1))
19261 {
19262 /* ASCII */
19263 if (c1 == 0)
19264 report_invalid_encoding(PG_MULE_INTERNAL,
19265 (const char *) mic, len);
19266 *p++ = c1;
19267 mic++;
19268 len--;
19269 continue;
19270 }
19271 l = pg_encoding_verifymb(PG_MULE_INTERNAL, (const char *) mic, len);
19272 if (l < 0)
19273 report_invalid_encoding(PG_MULE_INTERNAL,
19274 (const char *) mic, len);
19275 if (c1 == LC_CNS11643_1)
19276=====================================================================
19277Found a 9 line (101 tokens) duplication in the following files:
19278Starting at line 1737 of /home/shackle/pggit/postgresql/src/backend/utils/mb/wchar.c
19279Starting at line 1757 of /home/shackle/pggit/postgresql/src/backend/utils/mb/wchar.c
19280
19281 {pg_mule2wchar_with_len, pg_wchar2mule_with_len, pg_mule_mblen, pg_mule_dsplen, pg_mule_verifier, 4}, /* PG_MULE_INTERNAL */
19282 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN1 */
19283 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN2 */
19284 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN3 */
19285 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN4 */
19286 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN5 */
19287 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN6 */
19288 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN7 */
19289 {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN8 */
19290=====================================================================
19291Found a 38 line (101 tokens) duplication in the following files:
19292Starting at line 1160 of /home/shackle/pggit/postgresql/src/backend/utils/adt/jsonfuncs.c
19293Starting at line 1303 of /home/shackle/pggit/postgresql/src/backend/utils/adt/jsonfuncs.c
19294
19295 strcmp(fname, _state->path_names[lex_level - 1]) == 0)
19296 {
19297 if (lex_level < _state->npath)
19298 {
19299 /* done with this field so reset pathok */
19300 _state->pathok[lex_level] = false;
19301 }
19302 else
19303 {
19304 /* end of path, so we want this value */
19305 get_last = true;
19306 }
19307 }
19308
19309 /* for as_text scalar case, our work is already done */
19310 if (get_last && _state->result_start != NULL)
19311 {
19312 /*
19313 * make a text object from the string from the previously noted json
19314 * start up to the end of the previous token (the lexer is by now
19315 * ahead of us on whatever came after what we're interested in).
19316 */
19317 if (isnull && _state->normalize_results)
19318 _state->tresult = (text *) NULL;
19319 else
19320 {
19321 char *start = _state->result_start;
19322 int len = _state->lex->prev_token_terminator - start;
19323
19324 _state->tresult = cstring_to_text_with_len(start, len);
19325 }
19326
19327 /* this should be unnecessary but let's do it for cleanliness: */
19328 _state->result_start = NULL;
19329 }
19330}
19331
19332static void
19333=====================================================================
19334Found a 22 line (101 tokens) duplication in the following files:
19335Starting at line 3597 of /home/shackle/pggit/postgresql/src/backend/utils/adt/numeric.c
19336Starting at line 3685 of /home/shackle/pggit/postgresql/src/backend/utils/adt/numeric.c
19337
19338numeric_combine(PG_FUNCTION_ARGS)
19339{
19340 NumericAggState *state1;
19341 NumericAggState *state2;
19342 MemoryContext agg_context;
19343 MemoryContext old_context;
19344
19345 if (!AggCheckCallContext(fcinfo, &agg_context))
19346 elog(ERROR, "aggregate function called in non-aggregate context");
19347
19348 state1 = PG_ARGISNULL(0) ? NULL : (NumericAggState *) PG_GETARG_POINTER(0);
19349 state2 = PG_ARGISNULL(1) ? NULL : (NumericAggState *) PG_GETARG_POINTER(1);
19350
19351 if (state2 == NULL)
19352 PG_RETURN_POINTER(state1);
19353
19354 /* manually copy all fields from state2 to state1 */
19355 if (state1 == NULL)
19356 {
19357 old_context = MemoryContextSwitchTo(agg_context);
19358
19359 state1 = makeNumericAggStateCurrentContext(true);
19360=====================================================================
19361Found a 26 line (101 tokens) duplication in the following files:
19362Starting at line 5222 of /home/shackle/pggit/postgresql/src/backend/utils/adt/varlena.c
19363Starting at line 5279 of /home/shackle/pggit/postgresql/src/backend/utils/adt/varlena.c
19364
19365 arg = widthpos;
19366 if (arg >= nargs)
19367 ereport(ERROR,
19368 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
19369 errmsg("too few arguments for format()")));
19370
19371 /* Get the value and type of the selected argument */
19372 if (!funcvariadic)
19373 {
19374 value = PG_GETARG_DATUM(arg);
19375 isNull = PG_ARGISNULL(arg);
19376 typid = get_fn_expr_argtype(fcinfo->flinfo, arg);
19377 }
19378 else
19379 {
19380 value = elements[arg - 1];
19381 isNull = nulls[arg - 1];
19382 typid = element_type;
19383 }
19384 if (!OidIsValid(typid))
19385 elog(ERROR, "could not determine data type of format() input");
19386
19387 arg++;
19388
19389 /* We can treat NULL width the same as zero */
19390 if (isNull)
19391=====================================================================
19392Found a 25 line (101 tokens) duplication in the following files:
19393Starting at line 1375 of /home/shackle/pggit/postgresql/src/backend/commands/opclasscmds.c
19394Starting at line 1487 of /home/shackle/pggit/postgresql/src/backend/commands/opclasscmds.c
19395
19396 referenced.objectId = op->object;
19397 referenced.objectSubId = 0;
19398
19399 if (OidIsValid(opclassoid))
19400 {
19401 /* if contained in an opclass, use a NORMAL dep on operator */
19402 recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
19403
19404 /* ... and an INTERNAL dep on the opclass */
19405 referenced.classId = OperatorClassRelationId;
19406 referenced.objectId = opclassoid;
19407 referenced.objectSubId = 0;
19408 recordDependencyOn(&myself, &referenced, DEPENDENCY_INTERNAL);
19409 }
19410 else
19411 {
19412 /* if "loose" in the opfamily, use a AUTO dep on operator */
19413 recordDependencyOn(&myself, &referenced, DEPENDENCY_AUTO);
19414
19415 /* ... and an AUTO dep on the opfamily */
19416 referenced.classId = OperatorFamilyRelationId;
19417 referenced.objectId = opfamilyoid;
19418 referenced.objectSubId = 0;
19419 recordDependencyOn(&myself, &referenced, DEPENDENCY_AUTO);
19420 }
19421=====================================================================
19422Found a 18 line (101 tokens) duplication in the following files:
19423Starting at line 6189 of /home/shackle/pggit/postgresql/src/backend/commands/tablecmds.c
19424Starting at line 6248 of /home/shackle/pggit/postgresql/src/backend/commands/tablecmds.c
19425
19426 attrelation = heap_open(AttributeRelationId, RowExclusiveLock);
19427 tuple = SearchSysCacheCopyAttName(RelationGetRelid(rel), colName);
19428 if (!HeapTupleIsValid(tuple))
19429 ereport(ERROR,
19430 (errcode(ERRCODE_UNDEFINED_COLUMN),
19431 errmsg("column \"%s\" of relation \"%s\" does not exist",
19432 colName, RelationGetRelationName(rel))));
19433
19434 attTup = (Form_pg_attribute) GETSTRUCT(tuple);
19435 attnum = attTup->attnum;
19436
19437 if (attnum <= 0)
19438 ereport(ERROR,
19439 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
19440 errmsg("cannot alter system column \"%s\"",
19441 colName)));
19442
19443 if (!attTup->attidentity)
19444=====================================================================
19445Found a 27 line (100 tokens) duplication in the following files:
19446Starting at line 1837 of /home/shackle/pggit/postgresql/contrib/postgres_fdw/postgres_fdw.c
19447Starting at line 1913 of /home/shackle/pggit/postgresql/contrib/postgres_fdw/postgres_fdw.c
19448
19449postgresExecForeignUpdate(EState *estate,
19450 ResultRelInfo *resultRelInfo,
19451 TupleTableSlot *slot,
19452 TupleTableSlot *planSlot)
19453{
19454 PgFdwModifyState *fmstate = (PgFdwModifyState *) resultRelInfo->ri_FdwState;
19455 Datum datum;
19456 bool isNull;
19457 const char **p_values;
19458 PGresult *res;
19459 int n_rows;
19460
19461 /* Set up the prepared statement on the remote server, if we didn't yet */
19462 if (!fmstate->p_name)
19463 prepare_foreign_modify(fmstate);
19464
19465 /* Get the ctid that was passed up as a resjunk column */
19466 datum = ExecGetJunkAttribute(planSlot,
19467 fmstate->ctidAttno,
19468 &isNull);
19469 /* shouldn't ever get a null result... */
19470 if (isNull)
19471 elog(ERROR, "ctid is NULL");
19472
19473 /* Convert parameters needed by prepared statement to text form */
19474 p_values = convert_prep_stmt_params(fmstate,
19475 (ItemPointer) DatumGetPointer(datum),
19476=====================================================================
19477Found a 29 line (100 tokens) duplication in the following files:
19478Starting at line 32 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/ecpglib/misc.c
19479Starting at line 63 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/ecpglib/misc.c
19480Starting at line 21 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/compatlib/informix.c
19481
19482static struct sqlca_t sqlca_init =
19483{
19484 {
19485 'S', 'Q', 'L', 'C', 'A', ' ', ' ', ' '
19486 },
19487 sizeof(struct sqlca_t),
19488 0,
19489 {
19490 0,
19491 {
19492 0
19493 }
19494 },
19495 {
19496 'N', 'O', 'T', ' ', 'S', 'E', 'T', ' '
19497 },
19498 {
19499 0, 0, 0, 0, 0, 0
19500 },
19501 {
19502 0, 0, 0, 0, 0, 0, 0, 0
19503 },
19504 {
19505 '0', '0', '0', '0', '0'
19506 }
19507};
19508
19509#ifdef ENABLE_THREAD_SAFETY
19510static pthread_key_t sqlca_key;
19511=====================================================================
19512Found a 28 line (100 tokens) duplication in the following files:
19513Starting at line 378 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-sqlda.c
19514Starting at line 441 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-sqlda.c
19515
19516 { ECPGdeallocate(__LINE__, 0, NULL, "st_id2");
19517#line 172 "sqlda.pgc"
19518
19519if (sqlca.sqlcode < 0) exit (1);}
19520#line 172 "sqlda.pgc"
19521
19522
19523 /* SQLDA test for getting one record using an input descriptor */
19524
19525 /*
19526 * Input sqlda has to be built manually
19527 * sqlda_t contains 1 sqlvar_t structure already.
19528 */
19529 inp_sqlda = (sqlda_t *)malloc(sizeof(sqlda_t));
19530 memset(inp_sqlda, 0, sizeof(sqlda_t));
19531 inp_sqlda->sqln = 1;
19532
19533 inp_sqlda->sqlvar[0].sqltype = ECPGt_int;
19534 inp_sqlda->sqlvar[0].sqldata = (char *)&id;
19535
19536 printf("EXECUTE RECORD 4\n");
19537
19538 id = 4;
19539
19540 outp_sqlda = NULL;
19541
19542 strcpy(msg, "prepare");
19543 { ECPGprepare(__LINE__, NULL, 0, "st_id3", stmt2);
19544=====================================================================
19545Found a 23 line (100 tokens) duplication in the following files:
19546Starting at line 6035 of /home/shackle/pggit/postgresql/src/backend/optimizer/plan/planner.c
19547Starting at line 6152 of /home/shackle/pggit/postgresql/src/backend/optimizer/plan/planner.c
19548
19549 return true; /* use sort */
19550
19551 /* Set up mostly-dummy planner state */
19552 query = makeNode(Query);
19553 query->commandType = CMD_SELECT;
19554
19555 glob = makeNode(PlannerGlobal);
19556
19557 root = makeNode(PlannerInfo);
19558 root->parse = query;
19559 root->glob = glob;
19560 root->query_level = 1;
19561 root->planner_cxt = CurrentMemoryContext;
19562 root->wt_param_id = -1;
19563
19564 /* Build a minimal RTE for the rel */
19565 rte = makeNode(RangeTblEntry);
19566 rte->rtekind = RTE_RELATION;
19567 rte->relid = tableOid;
19568 rte->relkind = RELKIND_RELATION; /* Don't be too picky. */
19569 rte->rellockmode = AccessShareLock;
19570 rte->lateral = false;
19571 rte->inh = false;
19572=====================================================================
19573Found a 28 line (100 tokens) duplication in the following files:
19574Starting at line 1116 of /home/shackle/pggit/postgresql/src/backend/regex/regexec.c
19575Starting at line 1328 of /home/shackle/pggit/postgresql/src/backend/regex/regexec.c
19576
19577 endpts[k] = longest(v, d, endpts[k - 1], limit, (int *) NULL);
19578 if (ISERR())
19579 {
19580 FREE(endpts);
19581 return v->err;
19582 }
19583 if (endpts[k] == NULL)
19584 {
19585 /* no match possible, so see if we can shorten previous one */
19586 k--;
19587 goto backtrack;
19588 }
19589 MDEBUG(("%d: working endpoint %d: %ld\n",
19590 t->id, k, LOFF(endpts[k])));
19591
19592 /* k'th sub-match can no longer be considered verified */
19593 if (nverified >= k)
19594 nverified = k - 1;
19595
19596 if (endpts[k] != end)
19597 {
19598 /* haven't reached end yet, try another iteration if allowed */
19599 if (k >= max_matches)
19600 {
19601 /* must try to shorten some previous match */
19602 k--;
19603 goto backtrack;
19604 }
19605=====================================================================
19606Found a 5 line (100 tokens) duplication in the following files:
19607Starting at line 98 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
19608Starting at line 103 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
19609
19610 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
19611 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
19612 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
19613 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
19614 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
19615=====================================================================
19616Found a 23 line (100 tokens) duplication in the following files:
19617Starting at line 1049 of /home/shackle/pggit/postgresql/src/backend/utils/mmgr/mcxt.c
19618Starting at line 1119 of /home/shackle/pggit/postgresql/src/backend/utils/mmgr/mcxt.c
19619
19620 if (!AllocSizeIsValid(size))
19621 elog(ERROR, "invalid memory alloc request size %zu", size);
19622
19623 AssertNotInCriticalSection(context);
19624
19625 /* isReset must be false already */
19626 Assert(!context->isReset);
19627
19628 ret = context->methods->realloc(context, pointer, size);
19629 if (unlikely(ret == NULL))
19630 {
19631 MemoryContextStats(TopMemoryContext);
19632 ereport(ERROR,
19633 (errcode(ERRCODE_OUT_OF_MEMORY),
19634 errmsg("out of memory"),
19635 errdetail("Failed on request of size %zu in memory context \"%s\".",
19636 size, context->name)));
19637 }
19638
19639 VALGRIND_MEMPOOL_CHANGE(context, pointer, ret, size);
19640
19641 return ret;
19642}
19643=====================================================================
19644Found a 21 line (100 tokens) duplication in the following files:
19645Starting at line 278 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c
19646Starting at line 418 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c
19647
19648 l;
19649
19650 while (len > 0)
19651 {
19652 c1 = *mic;
19653 if (!IS_HIGHBIT_SET(c1))
19654 {
19655 /* ASCII */
19656 if (c1 == 0)
19657 report_invalid_encoding(PG_MULE_INTERNAL,
19658 (const char *) mic, len);
19659 *p++ = c1;
19660 mic++;
19661 len--;
19662 continue;
19663 }
19664 l = pg_encoding_verifymb(PG_MULE_INTERNAL, (const char *) mic, len);
19665 if (l < 0)
19666 report_invalid_encoding(PG_MULE_INTERNAL,
19667 (const char *) mic, len);
19668 if (c1 == LC_JISX0201K)
19669=====================================================================
19670Found a 22 line (100 tokens) duplication in the following files:
19671Starting at line 417 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c
19672Starting at line 307 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/euc_tw_and_big5.c
19673Starting at line 108 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/euc_kr_and_mic/euc_kr_and_mic.c
19674
19675 int c1;
19676 int l;
19677
19678 while (len > 0)
19679 {
19680 c1 = *mic;
19681 if (!IS_HIGHBIT_SET(c1))
19682 {
19683 /* ASCII */
19684 if (c1 == 0)
19685 report_invalid_encoding(PG_MULE_INTERNAL,
19686 (const char *) mic, len);
19687 *p++ = c1;
19688 mic++;
19689 len--;
19690 continue;
19691 }
19692 l = pg_encoding_verifymb(PG_MULE_INTERNAL, (const char *) mic, len);
19693 if (l < 0)
19694 report_invalid_encoding(PG_MULE_INTERNAL,
19695 (const char *) mic, len);
19696 if (c1 == LC_JISX0201K)
19697=====================================================================
19698Found a 18 line (100 tokens) duplication in the following files:
19699Starting at line 1997 of /home/shackle/pggit/postgresql/src/backend/utils/mb/wchar.c
19700Starting at line 2030 of /home/shackle/pggit/postgresql/src/backend/utils/mb/wchar.c
19701
19702 int l = pg_encoding_mblen(encoding, mbstr);
19703 char buf[8 * 5 + 1];
19704 char *p = buf;
19705 int j,
19706 jlimit;
19707
19708 jlimit = Min(l, len);
19709 jlimit = Min(jlimit, 8); /* prevent buffer overrun */
19710
19711 for (j = 0; j < jlimit; j++)
19712 {
19713 p += sprintf(p, "0x%02x", (unsigned char) mbstr[j]);
19714 if (j < jlimit - 1)
19715 p += sprintf(p, " ");
19716 }
19717
19718 ereport(ERROR,
19719 (errcode(ERRCODE_CHARACTER_NOT_IN_REPERTOIRE),
19720=====================================================================
19721Found a 34 line (100 tokens) duplication in the following files:
19722Starting at line 6267 of /home/shackle/pggit/postgresql/src/backend/utils/adt/numeric.c
19723Starting at line 6391 of /home/shackle/pggit/postgresql/src/backend/utils/adt/numeric.c
19724
19725 int64 val;
19726 bool neg;
19727 NumericVar rounded;
19728
19729 /* Round to nearest integer */
19730 init_var(&rounded);
19731 set_var_from_var(var, &rounded);
19732 round_var(&rounded, 0);
19733
19734 /* Check for zero input */
19735 strip_var(&rounded);
19736 ndigits = rounded.ndigits;
19737 if (ndigits == 0)
19738 {
19739 *result = 0;
19740 free_var(&rounded);
19741 return true;
19742 }
19743
19744 /*
19745 * For input like 10000000000, we must treat stripped digits as real. So
19746 * the loop assumes there are weight+1 digits before the decimal point.
19747 */
19748 weight = rounded.weight;
19749 Assert(weight >= 0 && ndigits <= weight + 1);
19750
19751 /*
19752 * Construct the result. To avoid issues with converting a value
19753 * corresponding to INT64_MIN (which can't be represented as a positive 64
19754 * bit two's complement integer), accumulate value as a negative number.
19755 */
19756 digits = rounded.digits;
19757 neg = (rounded.sign == NUMERIC_NEG);
19758 val = -digits[0];
19759=====================================================================
19760Found a 30 line (100 tokens) duplication in the following files:
19761Starting at line 4765 of /home/shackle/pggit/postgresql/src/backend/utils/adt/timestamp.c
19762Starting at line 4937 of /home/shackle/pggit/postgresql/src/backend/utils/adt/timestamp.c
19763
19764 case DTK_MICROSEC:
19765 result = tm->tm_sec * 1000000.0 + fsec;
19766 break;
19767
19768 case DTK_MILLISEC:
19769 result = tm->tm_sec * 1000.0 + fsec / 1000.0;
19770 break;
19771
19772 case DTK_SECOND:
19773 result = tm->tm_sec + fsec / 1000000.0;
19774 break;
19775
19776 case DTK_MINUTE:
19777 result = tm->tm_min;
19778 break;
19779
19780 case DTK_HOUR:
19781 result = tm->tm_hour;
19782 break;
19783
19784 case DTK_DAY:
19785 result = tm->tm_mday;
19786 break;
19787
19788 case DTK_MONTH:
19789 result = tm->tm_mon;
19790 break;
19791
19792 case DTK_QUARTER:
19793 result = (tm->tm_mon - 1) / 3 + 1;
19794=====================================================================
19795Found a 23 line (100 tokens) duplication in the following files:
19796Starting at line 2454 of /home/shackle/pggit/postgresql/src/backend/commands/typecmds.c
19797Starting at line 2673 of /home/shackle/pggit/postgresql/src/backend/commands/typecmds.c
19798
19799 tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(domainoid));
19800 if (!HeapTupleIsValid(tup))
19801 elog(ERROR, "cache lookup failed for type %u", domainoid);
19802
19803 /* Check it's a domain and check user has permission for ALTER DOMAIN */
19804 checkDomainOwner(tup);
19805
19806 /* Grab an appropriate lock on the pg_constraint relation */
19807 conrel = heap_open(ConstraintRelationId, RowExclusiveLock);
19808
19809 /* Find and remove the target constraint */
19810 ScanKeyInit(&skey[0],
19811 Anum_pg_constraint_conrelid,
19812 BTEqualStrategyNumber, F_OIDEQ,
19813 ObjectIdGetDatum(InvalidOid));
19814 ScanKeyInit(&skey[1],
19815 Anum_pg_constraint_contypid,
19816 BTEqualStrategyNumber, F_OIDEQ,
19817 ObjectIdGetDatum(domainoid));
19818 ScanKeyInit(&skey[2],
19819 Anum_pg_constraint_conname,
19820 BTEqualStrategyNumber, F_NAMEEQ,
19821 CStringGetDatum(constrName));
19822=====================================================================
19823Found a 26 line (100 tokens) duplication in the following files:
19824Starting at line 6092 of /home/shackle/pggit/postgresql/src/backend/commands/tablecmds.c
19825Starting at line 6246 of /home/shackle/pggit/postgresql/src/backend/commands/tablecmds.c
19826
19827 ColumnDef *cdef = castNode(ColumnDef, def);
19828
19829 attrelation = heap_open(AttributeRelationId, RowExclusiveLock);
19830
19831 tuple = SearchSysCacheCopyAttName(RelationGetRelid(rel), colName);
19832 if (!HeapTupleIsValid(tuple))
19833 ereport(ERROR,
19834 (errcode(ERRCODE_UNDEFINED_COLUMN),
19835 errmsg("column \"%s\" of relation \"%s\" does not exist",
19836 colName, RelationGetRelationName(rel))));
19837 attTup = (Form_pg_attribute) GETSTRUCT(tuple);
19838 attnum = attTup->attnum;
19839
19840 /* Can't alter a system attribute */
19841 if (attnum <= 0)
19842 ereport(ERROR,
19843 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
19844 errmsg("cannot alter system column \"%s\"",
19845 colName)));
19846
19847 /*
19848 * Creating a column as identity implies NOT NULL, so adding the identity
19849 * to an existing column that is not NOT NULL would create a state that
19850 * cannot be reproduced without contortions.
19851 */
19852 if (!attTup->attnotnull)