Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ~/pmd-bin-6.10.0/bin ./run.sh cpd --minimum-tokens 100 --language c --files /home/shackle/pggit/postgresql | pbcopy
- Found a 200 line (1115 tokens) duplication in the following files:
- Starting at line 440 of /home/shackle/pggit/postgresql/src/backend/access/hash/hashfunc.c
- Starting at line 680 of /home/shackle/pggit/postgresql/src/backend/access/hash/hashfunc.c
- if (((uintptr_t) k & UINT32_ALIGN_MASK) == 0)
- {
- /* Code path for aligned source data */
- register const uint32 *ka = (const uint32 *) k;
- /* handle most of the key */
- while (len >= 12)
- {
- a += ka[0];
- b += ka[1];
- c += ka[2];
- mix(a, b, c);
- ka += 3;
- len -= 12;
- }
- /* handle the last 11 bytes */
- k = (const unsigned char *) ka;
- #ifdef WORDS_BIGENDIAN
- switch (len)
- {
- case 11:
- c += ((uint32) k[10] << 8);
- /* fall through */
- case 10:
- c += ((uint32) k[9] << 16);
- /* fall through */
- case 9:
- c += ((uint32) k[8] << 24);
- /* fall through */
- case 8:
- /* the lowest byte of c is reserved for the length */
- b += ka[1];
- a += ka[0];
- break;
- case 7:
- b += ((uint32) k[6] << 8);
- /* fall through */
- case 6:
- b += ((uint32) k[5] << 16);
- /* fall through */
- case 5:
- b += ((uint32) k[4] << 24);
- /* fall through */
- case 4:
- a += ka[0];
- break;
- case 3:
- a += ((uint32) k[2] << 8);
- /* fall through */
- case 2:
- a += ((uint32) k[1] << 16);
- /* fall through */
- case 1:
- a += ((uint32) k[0] << 24);
- /* case 0: nothing left to add */
- }
- #else /* !WORDS_BIGENDIAN */
- switch (len)
- {
- case 11:
- c += ((uint32) k[10] << 24);
- /* fall through */
- case 10:
- c += ((uint32) k[9] << 16);
- /* fall through */
- case 9:
- c += ((uint32) k[8] << 8);
- /* fall through */
- case 8:
- /* the lowest byte of c is reserved for the length */
- b += ka[1];
- a += ka[0];
- break;
- case 7:
- b += ((uint32) k[6] << 16);
- /* fall through */
- case 6:
- b += ((uint32) k[5] << 8);
- /* fall through */
- case 5:
- b += k[4];
- /* fall through */
- case 4:
- a += ka[0];
- break;
- case 3:
- a += ((uint32) k[2] << 16);
- /* fall through */
- case 2:
- a += ((uint32) k[1] << 8);
- /* fall through */
- case 1:
- a += k[0];
- /* case 0: nothing left to add */
- }
- #endif /* WORDS_BIGENDIAN */
- }
- else
- {
- /* Code path for non-aligned source data */
- /* handle most of the key */
- while (len >= 12)
- {
- #ifdef WORDS_BIGENDIAN
- a += (k[3] + ((uint32) k[2] << 8) + ((uint32) k[1] << 16) + ((uint32) k[0] << 24));
- b += (k[7] + ((uint32) k[6] << 8) + ((uint32) k[5] << 16) + ((uint32) k[4] << 24));
- c += (k[11] + ((uint32) k[10] << 8) + ((uint32) k[9] << 16) + ((uint32) k[8] << 24));
- #else /* !WORDS_BIGENDIAN */
- a += (k[0] + ((uint32) k[1] << 8) + ((uint32) k[2] << 16) + ((uint32) k[3] << 24));
- b += (k[4] + ((uint32) k[5] << 8) + ((uint32) k[6] << 16) + ((uint32) k[7] << 24));
- c += (k[8] + ((uint32) k[9] << 8) + ((uint32) k[10] << 16) + ((uint32) k[11] << 24));
- #endif /* WORDS_BIGENDIAN */
- mix(a, b, c);
- k += 12;
- len -= 12;
- }
- /* handle the last 11 bytes */
- #ifdef WORDS_BIGENDIAN
- switch (len)
- {
- case 11:
- c += ((uint32) k[10] << 8);
- /* fall through */
- case 10:
- c += ((uint32) k[9] << 16);
- /* fall through */
- case 9:
- c += ((uint32) k[8] << 24);
- /* fall through */
- case 8:
- /* the lowest byte of c is reserved for the length */
- b += k[7];
- /* fall through */
- case 7:
- b += ((uint32) k[6] << 8);
- /* fall through */
- case 6:
- b += ((uint32) k[5] << 16);
- /* fall through */
- case 5:
- b += ((uint32) k[4] << 24);
- /* fall through */
- case 4:
- a += k[3];
- /* fall through */
- case 3:
- a += ((uint32) k[2] << 8);
- /* fall through */
- case 2:
- a += ((uint32) k[1] << 16);
- /* fall through */
- case 1:
- a += ((uint32) k[0] << 24);
- /* case 0: nothing left to add */
- }
- #else /* !WORDS_BIGENDIAN */
- switch (len)
- {
- case 11:
- c += ((uint32) k[10] << 24);
- /* fall through */
- case 10:
- c += ((uint32) k[9] << 16);
- /* fall through */
- case 9:
- c += ((uint32) k[8] << 8);
- /* fall through */
- case 8:
- /* the lowest byte of c is reserved for the length */
- b += ((uint32) k[7] << 24);
- /* fall through */
- case 7:
- b += ((uint32) k[6] << 16);
- /* fall through */
- case 6:
- b += ((uint32) k[5] << 8);
- /* fall through */
- case 5:
- b += k[4];
- /* fall through */
- case 4:
- a += ((uint32) k[3] << 24);
- /* fall through */
- case 3:
- a += ((uint32) k[2] << 16);
- /* fall through */
- case 2:
- a += ((uint32) k[1] << 8);
- /* fall through */
- case 1:
- a += k[0];
- /* case 0: nothing left to add */
- }
- #endif /* WORDS_BIGENDIAN */
- }
- final(a, b, c);
- =====================================================================
- Found a 52 line (1050 tokens) duplication in the following files:
- Starting at line 107 of /home/shackle/pggit/postgresql/contrib/pgcrypto/crypt-des.c
- Starting at line 387 of /home/shackle/pggit/postgresql/src/port/crypt.c
- static uint8 sbox[8][64] = {
- {
- 14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7,
- 0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8,
- 4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0,
- 15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13
- },
- {
- 15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10,
- 3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5,
- 0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15,
- 13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9
- },
- {
- 10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8,
- 13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1,
- 13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7,
- 1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12
- },
- {
- 7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15,
- 13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9,
- 10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4,
- 3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14
- },
- {
- 2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9,
- 14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6,
- 4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14,
- 11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3
- },
- {
- 12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11,
- 10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8,
- 9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6,
- 4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13
- },
- {
- 4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1,
- 13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6,
- 1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2,
- 6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12
- },
- {
- 13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7,
- 1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2,
- 7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8,
- 2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11
- }
- };
- static uint8 un_pbox[32];
- =====================================================================
- Found a 120 line (1049 tokens) duplication in the following files:
- Starting at line 267 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/ecpglib/sqlda.c
- Starting at line 456 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/ecpglib/sqlda.c
- offset = sqlda_compat_empty_size(res);
- /*
- * Set sqlvar[i]->sqldata pointers and convert values to correct format
- */
- for (i = 0; i < sqlda->sqld; i++)
- {
- int isnull;
- int datalen;
- bool set_data = true;
- switch (sqlda->sqlvar[i].sqltype)
- {
- case ECPGt_short:
- case ECPGt_unsigned_short:
- ecpg_sqlda_align_add_size(offset, sizeof(short), sizeof(short), &offset, &next_offset);
- sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
- sqlda->sqlvar[i].sqllen = sizeof(short);
- break;
- case ECPGt_int:
- case ECPGt_unsigned_int:
- ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(int), &offset, &next_offset);
- sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
- sqlda->sqlvar[i].sqllen = sizeof(int);
- break;
- case ECPGt_long:
- case ECPGt_unsigned_long:
- ecpg_sqlda_align_add_size(offset, sizeof(long), sizeof(long), &offset, &next_offset);
- sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
- sqlda->sqlvar[i].sqllen = sizeof(long);
- break;
- case ECPGt_long_long:
- case ECPGt_unsigned_long_long:
- ecpg_sqlda_align_add_size(offset, sizeof(long long), sizeof(long long), &offset, &next_offset);
- sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
- sqlda->sqlvar[i].sqllen = sizeof(long long);
- break;
- case ECPGt_bool:
- ecpg_sqlda_align_add_size(offset, sizeof(bool), sizeof(bool), &offset, &next_offset);
- sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
- sqlda->sqlvar[i].sqllen = sizeof(bool);
- break;
- case ECPGt_float:
- ecpg_sqlda_align_add_size(offset, sizeof(float), sizeof(float), &offset, &next_offset);
- sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
- sqlda->sqlvar[i].sqllen = sizeof(float);
- break;
- case ECPGt_double:
- ecpg_sqlda_align_add_size(offset, sizeof(double), sizeof(double), &offset, &next_offset);
- sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
- sqlda->sqlvar[i].sqllen = sizeof(double);
- break;
- case ECPGt_decimal:
- ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(decimal), &offset, &next_offset);
- sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
- sqlda->sqlvar[i].sqllen = sizeof(decimal);
- break;
- case ECPGt_numeric:
- {
- numeric *num;
- char *val;
- set_data = false;
- ecpg_sqlda_align_add_size(offset, sizeof(NumericDigit *), sizeof(numeric), &offset, &next_offset);
- sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
- sqlda->sqlvar[i].sqllen = sizeof(numeric);
- if (PQgetisnull(res, row, i))
- {
- ECPGset_noind_null(ECPGt_numeric, sqlda->sqlvar[i].sqldata);
- break;
- }
- val = PQgetvalue(res, row, i);
- num = PGTYPESnumeric_from_asc(val, NULL);
- if (!num)
- {
- ECPGset_noind_null(ECPGt_numeric, sqlda->sqlvar[i].sqldata);
- break;
- }
- memcpy(sqlda->sqlvar[i].sqldata, num, sizeof(numeric));
- if (num->buf)
- {
- ecpg_sqlda_align_add_size(next_offset, sizeof(int), num->digits - num->buf + num->ndigits, &offset, &next_offset);
- memcpy((char *) sqlda + offset, num->buf, num->digits - num->buf + num->ndigits);
- ((numeric *) sqlda->sqlvar[i].sqldata)->buf = (NumericDigit *) sqlda + offset;
- ((numeric *) sqlda->sqlvar[i].sqldata)->digits = (NumericDigit *) sqlda + offset + (num->digits - num->buf);
- }
- PGTYPESnumeric_free(num);
- break;
- }
- case ECPGt_date:
- ecpg_sqlda_align_add_size(offset, sizeof(date), sizeof(date), &offset, &next_offset);
- sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
- sqlda->sqlvar[i].sqllen = sizeof(date);
- break;
- case ECPGt_timestamp:
- ecpg_sqlda_align_add_size(offset, sizeof(int64), sizeof(timestamp), &offset, &next_offset);
- sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
- sqlda->sqlvar[i].sqllen = sizeof(timestamp);
- break;
- case ECPGt_interval:
- ecpg_sqlda_align_add_size(offset, sizeof(int64), sizeof(interval), &offset, &next_offset);
- sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
- sqlda->sqlvar[i].sqllen = sizeof(interval);
- break;
- case ECPGt_char:
- case ECPGt_unsigned_char:
- case ECPGt_string:
- default:
- datalen = strlen(PQgetvalue(res, row, i)) + 1;
- ecpg_sqlda_align_add_size(offset, sizeof(int), datalen, &offset, &next_offset);
- sqlda->sqlvar[i].sqldata = (char *) sqlda + offset;
- sqlda->sqlvar[i].sqllen = datalen;
- =====================================================================
- Found a 122 line (589 tokens) duplication in the following files:
- Starting at line 1295 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
- Starting at line 1539 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
- int result = 0;
- Oid tupType1;
- Oid tupType2;
- int32 tupTypmod1;
- int32 tupTypmod2;
- TupleDesc tupdesc1;
- TupleDesc tupdesc2;
- HeapTupleData tuple1;
- HeapTupleData tuple2;
- int ncolumns1;
- int ncolumns2;
- RecordCompareData *my_extra;
- int ncols;
- Datum *values1;
- Datum *values2;
- bool *nulls1;
- bool *nulls2;
- int i1;
- int i2;
- int j;
- /* Extract type info from the tuples */
- tupType1 = HeapTupleHeaderGetTypeId(record1);
- tupTypmod1 = HeapTupleHeaderGetTypMod(record1);
- tupdesc1 = lookup_rowtype_tupdesc(tupType1, tupTypmod1);
- ncolumns1 = tupdesc1->natts;
- tupType2 = HeapTupleHeaderGetTypeId(record2);
- tupTypmod2 = HeapTupleHeaderGetTypMod(record2);
- tupdesc2 = lookup_rowtype_tupdesc(tupType2, tupTypmod2);
- ncolumns2 = tupdesc2->natts;
- /* Build temporary HeapTuple control structures */
- tuple1.t_len = HeapTupleHeaderGetDatumLength(record1);
- ItemPointerSetInvalid(&(tuple1.t_self));
- tuple1.t_tableOid = InvalidOid;
- tuple1.t_data = record1;
- tuple2.t_len = HeapTupleHeaderGetDatumLength(record2);
- ItemPointerSetInvalid(&(tuple2.t_self));
- tuple2.t_tableOid = InvalidOid;
- tuple2.t_data = record2;
- /*
- * We arrange to look up the needed comparison info just once per series
- * of calls, assuming the record types don't change underneath us.
- */
- ncols = Max(ncolumns1, ncolumns2);
- my_extra = (RecordCompareData *) fcinfo->flinfo->fn_extra;
- if (my_extra == NULL ||
- my_extra->ncolumns < ncols)
- {
- fcinfo->flinfo->fn_extra =
- MemoryContextAlloc(fcinfo->flinfo->fn_mcxt,
- offsetof(RecordCompareData, columns) +
- ncols * sizeof(ColumnCompareData));
- my_extra = (RecordCompareData *) fcinfo->flinfo->fn_extra;
- my_extra->ncolumns = ncols;
- my_extra->record1_type = InvalidOid;
- my_extra->record1_typmod = 0;
- my_extra->record2_type = InvalidOid;
- my_extra->record2_typmod = 0;
- }
- if (my_extra->record1_type != tupType1 ||
- my_extra->record1_typmod != tupTypmod1 ||
- my_extra->record2_type != tupType2 ||
- my_extra->record2_typmod != tupTypmod2)
- {
- MemSet(my_extra->columns, 0, ncols * sizeof(ColumnCompareData));
- my_extra->record1_type = tupType1;
- my_extra->record1_typmod = tupTypmod1;
- my_extra->record2_type = tupType2;
- my_extra->record2_typmod = tupTypmod2;
- }
- /* Break down the tuples into fields */
- values1 = (Datum *) palloc(ncolumns1 * sizeof(Datum));
- nulls1 = (bool *) palloc(ncolumns1 * sizeof(bool));
- heap_deform_tuple(&tuple1, tupdesc1, values1, nulls1);
- values2 = (Datum *) palloc(ncolumns2 * sizeof(Datum));
- nulls2 = (bool *) palloc(ncolumns2 * sizeof(bool));
- heap_deform_tuple(&tuple2, tupdesc2, values2, nulls2);
- /*
- * Scan corresponding columns, allowing for dropped columns in different
- * places in the two rows. i1 and i2 are physical column indexes, j is
- * the logical column index.
- */
- i1 = i2 = j = 0;
- while (i1 < ncolumns1 || i2 < ncolumns2)
- {
- Form_pg_attribute att1;
- Form_pg_attribute att2;
- /*
- * Skip dropped columns
- */
- if (i1 < ncolumns1 && TupleDescAttr(tupdesc1, i1)->attisdropped)
- {
- i1++;
- continue;
- }
- if (i2 < ncolumns2 && TupleDescAttr(tupdesc2, i2)->attisdropped)
- {
- i2++;
- continue;
- }
- if (i1 >= ncolumns1 || i2 >= ncolumns2)
- break; /* we'll deal with mismatch below loop */
- att1 = TupleDescAttr(tupdesc1, i1);
- att2 = TupleDescAttr(tupdesc2, i2);
- /*
- * Have two matching columns, they must be same type
- */
- if (att1->atttypid != att2->atttypid)
- ereport(ERROR,
- (errcode(ERRCODE_DATATYPE_MISMATCH),
- errmsg("cannot compare dissimilar column types %s and %s at record column %d",
- format_type_be(att1->atttypid),
- format_type_be(att2->atttypid),
- j + 1)));
- =====================================================================
- Found a 165 line (535 tokens) duplication in the following files:
- Starting at line 19 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/thread-thread_implicit.c
- Starting at line 18 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/thread-thread.c
- int
- main(void)
- {
- printf("No threading enabled.\n");
- return 0;
- }
- #else
- #ifndef WIN32
- #include <pthread.h>
- #else
- #include <windows.h>
- #include <locale.h>
- #endif
- #line 1 "regression.h"
- #line 24 "thread_implicit.pgc"
- void *test_thread(void *arg);
- int nthreads = 10;
- int iterations = 20;
- int main()
- {
- #ifndef WIN32
- pthread_t *threads;
- #else
- HANDLE *threads;
- #endif
- int n;
- /* exec sql begin declare section */
- #line 40 "thread_implicit.pgc"
- int l_rows ;
- /* exec sql end declare section */
- #line 41 "thread_implicit.pgc"
- /* Do not switch on debug output for regression tests. The threads get executed in
- * more or less random order */
- /* ECPGdebug(1, stderr); */
- /* setup test_thread table */
- { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0); }
- #line 48 "thread_implicit.pgc"
- { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table test_thread", ECPGt_EOIT, ECPGt_EORT);}
- #line 49 "thread_implicit.pgc"
- /* DROP might fail */
- { ECPGtrans(__LINE__, NULL, "commit");}
- #line 50 "thread_implicit.pgc"
- { 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);}
- #line 55 "thread_implicit.pgc"
- { ECPGtrans(__LINE__, NULL, "commit");}
- #line 56 "thread_implicit.pgc"
- { ECPGdisconnect(__LINE__, "CURRENT");}
- #line 57 "thread_implicit.pgc"
- /* create, and start, threads */
- threads = calloc(nthreads, sizeof(threads[0]));
- if( threads == NULL )
- {
- fprintf(stderr, "Cannot alloc memory\n");
- return 1;
- }
- for( n = 0; n < nthreads; n++ )
- {
- #ifndef WIN32
- pthread_create(&threads[n], NULL, test_thread, (void *) (long) (n + 1));
- #else
- threads[n] = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) test_thread, (void *) (n+1), 0, NULL);
- #endif
- }
- /* wait for thread completion */
- #ifndef WIN32
- for( n = 0; n < nthreads; n++ )
- {
- pthread_join(threads[n], NULL);
- }
- #else
- WaitForMultipleObjects(nthreads, threads, TRUE, INFINITE);
- #endif
- free(threads);
- /* and check results */
- { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0); }
- #line 87 "thread_implicit.pgc"
- { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from test_thread", ECPGt_EOIT,
- ECPGt_int,&(l_rows),(long)1,(long)1,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
- #line 88 "thread_implicit.pgc"
- { ECPGtrans(__LINE__, NULL, "commit");}
- #line 89 "thread_implicit.pgc"
- { ECPGdisconnect(__LINE__, "CURRENT");}
- #line 90 "thread_implicit.pgc"
- if( l_rows == (nthreads * iterations) )
- printf("Success.\n");
- else
- printf("ERROR: Failure - expecting %d rows, got %d.\n", nthreads * iterations, l_rows);
- return 0;
- }
- void *test_thread(void *arg)
- {
- long threadnum = (long)arg;
- /* exec sql begin declare section */
- #line 104 "thread_implicit.pgc"
- int l_i ;
- #line 105 "thread_implicit.pgc"
- char l_connection [ 128 ] ;
- /* exec sql end declare section */
- #line 106 "thread_implicit.pgc"
- #ifdef WIN32
- #ifdef _MSC_VER /* requires MSVC */
- _configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
- #endif
- #endif
- /* build up connection name, and connect to database */
- #ifndef _MSC_VER
- snprintf(l_connection, sizeof(l_connection), "thread_%03ld", threadnum);
- #else
- _snprintf(l_connection, sizeof(l_connection), "thread_%03ld", threadnum);
- #endif
- /* exec sql whenever sqlerror sqlprint ; */
- #line 120 "thread_implicit.pgc"
- { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , l_connection, 0);
- #line 121 "thread_implicit.pgc"
- if (sqlca.sqlcode < 0) sqlprint();}
- #line 121 "thread_implicit.pgc"
- if( sqlca.sqlcode != 0 )
- {
- printf("%s: ERROR: cannot connect to database!\n", l_connection);
- return NULL;
- }
- { ECPGtrans(__LINE__, NULL, "begin");
- =====================================================================
- Found a 24 line (524 tokens) duplication in the following files:
- Starting at line 21 of /home/shackle/pggit/postgresql/contrib/ltree/_ltree_gist.c
- Starting at line 40 of /home/shackle/pggit/postgresql/contrib/pg_trgm/trgm_gist.c
- Starting at line 21 of /home/shackle/pggit/postgresql/contrib/intarray/_intbig_gist.c
- PG_FUNCTION_INFO_V1(_ltree_consistent);
- #define GETENTRY(vec,pos) ((ltree_gist *) DatumGetPointer((vec)->vector[(pos)].key))
- #define NEXTVAL(x) ( (ltree*)( (char*)(x) + INTALIGN( VARSIZE(x) ) ) )
- /* Number of one-bits in an unsigned byte */
- static const uint8 number_of_ones[256] = {
- 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
- 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
- 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
- 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
- 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
- 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
- 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
- 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
- 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
- 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
- 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
- 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
- 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
- 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
- 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
- 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8
- };
- =====================================================================
- Found a 29 line (524 tokens) duplication in the following files:
- Starting at line 21 of /home/shackle/pggit/postgresql/contrib/ltree/_ltree_gist.c
- Starting at line 56 of /home/shackle/pggit/postgresql/src/backend/utils/adt/tsgistidx.c
- PG_FUNCTION_INFO_V1(_ltree_consistent);
- #define GETENTRY(vec,pos) ((ltree_gist *) DatumGetPointer((vec)->vector[(pos)].key))
- #define NEXTVAL(x) ( (ltree*)( (char*)(x) + INTALIGN( VARSIZE(x) ) ) )
- /* Number of one-bits in an unsigned byte */
- static const uint8 number_of_ones[256] = {
- 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
- 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
- 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
- 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
- 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
- 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
- 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
- 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
- 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
- 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
- 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
- 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
- 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
- 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
- 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
- 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8
- };
- #define WISH_F(a,b,c) (double)( -(double)(((a)-(b))*((a)-(b))*((a)-(b)))*(c) )
- static void
- =====================================================================
- Found a 24 line (523 tokens) duplication in the following files:
- Starting at line 21 of /home/shackle/pggit/postgresql/contrib/ltree/_ltree_gist.c
- Starting at line 40 of /home/shackle/pggit/postgresql/contrib/pg_trgm/trgm_gist.c
- Starting at line 21 of /home/shackle/pggit/postgresql/contrib/intarray/_intbig_gist.c
- Starting at line 107 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
- Starting at line 56 of /home/shackle/pggit/postgresql/src/backend/utils/adt/tsgistidx.c
- PG_FUNCTION_INFO_V1(_ltree_consistent);
- #define GETENTRY(vec,pos) ((ltree_gist *) DatumGetPointer((vec)->vector[(pos)].key))
- #define NEXTVAL(x) ( (ltree*)( (char*)(x) + INTALIGN( VARSIZE(x) ) ) )
- /* Number of one-bits in an unsigned byte */
- static const uint8 number_of_ones[256] = {
- 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
- 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
- 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
- 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
- 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
- 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
- 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
- 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
- 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
- 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
- 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
- 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
- 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
- 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
- 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
- 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8
- };
- =====================================================================
- Found a 67 line (512 tokens) duplication in the following files:
- Starting at line 421 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/dt_common.c
- Starting at line 168 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
- };
- static const datetkn deltatktbl[] = {
- /* text, token, lexval */
- {"@", IGNORE_DTF, 0}, /* postgres relative prefix */
- {DAGO, AGO, 0}, /* "ago" indicates negative time offset */
- {"c", UNITS, DTK_CENTURY}, /* "century" relative */
- {"cent", UNITS, DTK_CENTURY}, /* "century" relative */
- {"centuries", UNITS, DTK_CENTURY}, /* "centuries" relative */
- {DCENTURY, UNITS, DTK_CENTURY}, /* "century" relative */
- {"d", UNITS, DTK_DAY}, /* "day" relative */
- {DDAY, UNITS, DTK_DAY}, /* "day" relative */
- {"days", UNITS, DTK_DAY}, /* "days" relative */
- {"dec", UNITS, DTK_DECADE}, /* "decade" relative */
- {DDECADE, UNITS, DTK_DECADE}, /* "decade" relative */
- {"decades", UNITS, DTK_DECADE}, /* "decades" relative */
- {"decs", UNITS, DTK_DECADE}, /* "decades" relative */
- {"h", UNITS, DTK_HOUR}, /* "hour" relative */
- {DHOUR, UNITS, DTK_HOUR}, /* "hour" relative */
- {"hours", UNITS, DTK_HOUR}, /* "hours" relative */
- {"hr", UNITS, DTK_HOUR}, /* "hour" relative */
- {"hrs", UNITS, DTK_HOUR}, /* "hours" relative */
- {INVALID, RESERV, DTK_INVALID}, /* reserved for invalid time */
- {"m", UNITS, DTK_MINUTE}, /* "minute" relative */
- {"microsecon", UNITS, DTK_MICROSEC}, /* "microsecond" relative */
- {"mil", UNITS, DTK_MILLENNIUM}, /* "millennium" relative */
- {"millennia", UNITS, DTK_MILLENNIUM}, /* "millennia" relative */
- {DMILLENNIUM, UNITS, DTK_MILLENNIUM}, /* "millennium" relative */
- {"millisecon", UNITS, DTK_MILLISEC}, /* relative */
- {"mils", UNITS, DTK_MILLENNIUM}, /* "millennia" relative */
- {"min", UNITS, DTK_MINUTE}, /* "minute" relative */
- {"mins", UNITS, DTK_MINUTE}, /* "minutes" relative */
- {DMINUTE, UNITS, DTK_MINUTE}, /* "minute" relative */
- {"minutes", UNITS, DTK_MINUTE}, /* "minutes" relative */
- {"mon", UNITS, DTK_MONTH}, /* "months" relative */
- {"mons", UNITS, DTK_MONTH}, /* "months" relative */
- {DMONTH, UNITS, DTK_MONTH}, /* "month" relative */
- {"months", UNITS, DTK_MONTH},
- {"ms", UNITS, DTK_MILLISEC},
- {"msec", UNITS, DTK_MILLISEC},
- {DMILLISEC, UNITS, DTK_MILLISEC},
- {"mseconds", UNITS, DTK_MILLISEC},
- {"msecs", UNITS, DTK_MILLISEC},
- {"qtr", UNITS, DTK_QUARTER}, /* "quarter" relative */
- {DQUARTER, UNITS, DTK_QUARTER}, /* "quarter" relative */
- {"s", UNITS, DTK_SECOND},
- {"sec", UNITS, DTK_SECOND},
- {DSECOND, UNITS, DTK_SECOND},
- {"seconds", UNITS, DTK_SECOND},
- {"secs", UNITS, DTK_SECOND},
- {DTIMEZONE, UNITS, DTK_TZ}, /* "timezone" time offset */
- {"timezone_h", UNITS, DTK_TZ_HOUR}, /* timezone hour units */
- {"timezone_m", UNITS, DTK_TZ_MINUTE}, /* timezone minutes units */
- {"undefined", RESERV, DTK_INVALID}, /* pre-v6.1 invalid time */
- {"us", UNITS, DTK_MICROSEC}, /* "microsecond" relative */
- {"usec", UNITS, DTK_MICROSEC}, /* "microsecond" relative */
- {DMICROSEC, UNITS, DTK_MICROSEC}, /* "microsecond" relative */
- {"useconds", UNITS, DTK_MICROSEC}, /* "microseconds" relative */
- {"usecs", UNITS, DTK_MICROSEC}, /* "microseconds" relative */
- {"w", UNITS, DTK_WEEK}, /* "week" relative */
- {DWEEK, UNITS, DTK_WEEK}, /* "week" relative */
- {"weeks", UNITS, DTK_WEEK}, /* "weeks" relative */
- {"y", UNITS, DTK_YEAR}, /* "year" relative */
- {DYEAR, UNITS, DTK_YEAR}, /* "year" relative */
- {"years", UNITS, DTK_YEAR}, /* "years" relative */
- {"yr", UNITS, DTK_YEAR}, /* "year" relative */
- {"yrs", UNITS, DTK_YEAR}, /* "years" relative */
- =====================================================================
- Found a 104 line (498 tokens) duplication in the following files:
- Starting at line 181 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-describe.c
- Starting at line 343 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-describe.c
- { ECPGdescribe(__LINE__, 0, NULL, "st_id1",
- ECPGt_descriptor, "desc4", 0L, 0L, 0L,
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
- #line 61 "describe.pgc"
- strcpy(msg, "get descriptor");
- { ECPGget_desc_header(__LINE__, "desc1", &(count1));
- #line 64 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 64 "describe.pgc"
- { ECPGget_desc_header(__LINE__, "desc2", &(count2));
- #line 65 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 65 "describe.pgc"
- { ECPGget_desc_header(__LINE__, "desc3", &(count3));
- #line 66 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 66 "describe.pgc"
- { ECPGget_desc_header(__LINE__, "desc4", &(count4));
- #line 67 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 67 "describe.pgc"
- if (!(count1 == count2 && count1 == count3 && count1 == count4))
- exit(1);
- for (i = 1; i <= count1; i++)
- {
- { ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
- ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
- #line 74 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 74 "describe.pgc"
- { ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
- ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
- #line 75 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 75 "describe.pgc"
- { ECPGget_desc(__LINE__, "desc3", i,ECPGd_name,
- ECPGt_char,(field_name3),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
- #line 76 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 76 "describe.pgc"
- { ECPGget_desc(__LINE__, "desc4", i,ECPGd_name,
- ECPGt_char,(field_name4),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
- #line 77 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 77 "describe.pgc"
- printf("field_name 1 '%s' 2 '%s' 3 '%s' 4 '%s'\n",
- field_name1, field_name2, field_name3, field_name4);
- }
- strcpy(msg, "deallocate");
- ECPGdeallocate_desc(__LINE__, "desc1");
- #line 83 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);
- #line 83 "describe.pgc"
- ECPGdeallocate_desc(__LINE__, "desc2");
- #line 84 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);
- #line 84 "describe.pgc"
- ECPGdeallocate_desc(__LINE__, "desc3");
- #line 85 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);
- #line 85 "describe.pgc"
- ECPGdeallocate_desc(__LINE__, "desc4");
- #line 86 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);
- #line 86 "describe.pgc"
- { ECPGdeallocate(__LINE__, 0, NULL, "st_id1");
- =====================================================================
- Found a 132 line (491 tokens) duplication in the following files:
- Starting at line 194 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/interval.c
- Starting at line 3589 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
- tm->tm_mon += (fval * 12);
- if (unit == '\0')
- return 0;
- if (unit == 'T')
- {
- datepart = false;
- havefield = false;
- continue;
- }
- dterr = ParseISO8601Number(str, &str, &val, &fval);
- if (dterr)
- return dterr;
- tm->tm_mon += val;
- AdjustFractDays(fval, tm, fsec, DAYS_PER_MONTH);
- if (*str == '\0')
- return 0;
- if (*str == 'T')
- {
- datepart = false;
- havefield = false;
- continue;
- }
- if (*str != '-')
- return DTERR_BAD_FORMAT;
- str++;
- dterr = ParseISO8601Number(str, &str, &val, &fval);
- if (dterr)
- return dterr;
- tm->tm_mday += val;
- AdjustFractSeconds(fval, tm, fsec, SECS_PER_DAY);
- if (*str == '\0')
- return 0;
- if (*str == 'T')
- {
- datepart = false;
- havefield = false;
- continue;
- }
- return DTERR_BAD_FORMAT;
- default:
- /* not a valid date unit suffix */
- return DTERR_BAD_FORMAT;
- }
- }
- else
- {
- switch (unit) /* after T: H M S */
- {
- case 'H':
- tm->tm_hour += val;
- AdjustFractSeconds(fval, tm, fsec, SECS_PER_HOUR);
- break;
- case 'M':
- tm->tm_min += val;
- AdjustFractSeconds(fval, tm, fsec, SECS_PER_MINUTE);
- break;
- case 'S':
- tm->tm_sec += val;
- AdjustFractSeconds(fval, tm, fsec, 1);
- break;
- case '\0': /* ISO 8601 4.4.3.3 Alternative Format */
- if (ISO8601IntegerWidth(fieldstart) == 6 && !havefield)
- {
- tm->tm_hour += val / 10000;
- tm->tm_min += (val / 100) % 100;
- tm->tm_sec += val % 100;
- AdjustFractSeconds(fval, tm, fsec, 1);
- return 0;
- }
- /* Else fall through to extended alternative format */
- /* FALLTHROUGH */
- case ':': /* ISO 8601 4.4.3.3 Alternative Format,
- * Extended */
- if (havefield)
- return DTERR_BAD_FORMAT;
- tm->tm_hour += val;
- AdjustFractSeconds(fval, tm, fsec, SECS_PER_HOUR);
- if (unit == '\0')
- return 0;
- dterr = ParseISO8601Number(str, &str, &val, &fval);
- if (dterr)
- return dterr;
- tm->tm_min += val;
- AdjustFractSeconds(fval, tm, fsec, SECS_PER_MINUTE);
- if (*str == '\0')
- return 0;
- if (*str != ':')
- return DTERR_BAD_FORMAT;
- str++;
- dterr = ParseISO8601Number(str, &str, &val, &fval);
- if (dterr)
- return dterr;
- tm->tm_sec += val;
- AdjustFractSeconds(fval, tm, fsec, 1);
- if (*str == '\0')
- return 0;
- return DTERR_BAD_FORMAT;
- default:
- /* not a valid time unit suffix */
- return DTERR_BAD_FORMAT;
- }
- }
- havefield = true;
- }
- return 0;
- }
- /* copy&pasted from .../src/backend/utils/adt/datetime.c
- * with 3 exceptions
- *
- * * changesd struct pg_tm to struct tm
- *
- * * ECPG code called this without a 'range' parameter
- * removed 'int range' from the argument list and
- * places where DecodeTime is called; and added
- * int range = INTERVAL_FULL_RANGE;
- *
- * * ECPG seems not to have a global IntervalStyle
- * so added
- * int IntervalStyle = INTSTYLE_POSTGRES;
- */
- int
- =====================================================================
- Found a 96 line (481 tokens) duplication in the following files:
- Starting at line 788 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
- Starting at line 1030 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
- int result = 0;
- Oid tupType1;
- Oid tupType2;
- int32 tupTypmod1;
- int32 tupTypmod2;
- TupleDesc tupdesc1;
- TupleDesc tupdesc2;
- HeapTupleData tuple1;
- HeapTupleData tuple2;
- int ncolumns1;
- int ncolumns2;
- RecordCompareData *my_extra;
- int ncols;
- Datum *values1;
- Datum *values2;
- bool *nulls1;
- bool *nulls2;
- int i1;
- int i2;
- int j;
- check_stack_depth(); /* recurses for record-type columns */
- /* Extract type info from the tuples */
- tupType1 = HeapTupleHeaderGetTypeId(record1);
- tupTypmod1 = HeapTupleHeaderGetTypMod(record1);
- tupdesc1 = lookup_rowtype_tupdesc(tupType1, tupTypmod1);
- ncolumns1 = tupdesc1->natts;
- tupType2 = HeapTupleHeaderGetTypeId(record2);
- tupTypmod2 = HeapTupleHeaderGetTypMod(record2);
- tupdesc2 = lookup_rowtype_tupdesc(tupType2, tupTypmod2);
- ncolumns2 = tupdesc2->natts;
- /* Build temporary HeapTuple control structures */
- tuple1.t_len = HeapTupleHeaderGetDatumLength(record1);
- ItemPointerSetInvalid(&(tuple1.t_self));
- tuple1.t_tableOid = InvalidOid;
- tuple1.t_data = record1;
- tuple2.t_len = HeapTupleHeaderGetDatumLength(record2);
- ItemPointerSetInvalid(&(tuple2.t_self));
- tuple2.t_tableOid = InvalidOid;
- tuple2.t_data = record2;
- /*
- * We arrange to look up the needed comparison info just once per series
- * of calls, assuming the record types don't change underneath us.
- */
- ncols = Max(ncolumns1, ncolumns2);
- my_extra = (RecordCompareData *) fcinfo->flinfo->fn_extra;
- if (my_extra == NULL ||
- my_extra->ncolumns < ncols)
- {
- fcinfo->flinfo->fn_extra =
- MemoryContextAlloc(fcinfo->flinfo->fn_mcxt,
- offsetof(RecordCompareData, columns) +
- ncols * sizeof(ColumnCompareData));
- my_extra = (RecordCompareData *) fcinfo->flinfo->fn_extra;
- my_extra->ncolumns = ncols;
- my_extra->record1_type = InvalidOid;
- my_extra->record1_typmod = 0;
- my_extra->record2_type = InvalidOid;
- my_extra->record2_typmod = 0;
- }
- if (my_extra->record1_type != tupType1 ||
- my_extra->record1_typmod != tupTypmod1 ||
- my_extra->record2_type != tupType2 ||
- my_extra->record2_typmod != tupTypmod2)
- {
- MemSet(my_extra->columns, 0, ncols * sizeof(ColumnCompareData));
- my_extra->record1_type = tupType1;
- my_extra->record1_typmod = tupTypmod1;
- my_extra->record2_type = tupType2;
- my_extra->record2_typmod = tupTypmod2;
- }
- /* Break down the tuples into fields */
- values1 = (Datum *) palloc(ncolumns1 * sizeof(Datum));
- nulls1 = (bool *) palloc(ncolumns1 * sizeof(bool));
- heap_deform_tuple(&tuple1, tupdesc1, values1, nulls1);
- values2 = (Datum *) palloc(ncolumns2 * sizeof(Datum));
- nulls2 = (bool *) palloc(ncolumns2 * sizeof(bool));
- heap_deform_tuple(&tuple2, tupdesc2, values2, nulls2);
- /*
- * Scan corresponding columns, allowing for dropped columns in different
- * places in the two rows. i1 and i2 are physical column indexes, j is
- * the logical column index.
- */
- i1 = i2 = j = 0;
- while (i1 < ncolumns1 || i2 < ncolumns2)
- {
- Form_pg_attribute att1;
- Form_pg_attribute att2;
- TypeCacheEntry *typentry;
- Oid collation;
- =====================================================================
- Found a 84 line (470 tokens) duplication in the following files:
- Starting at line 881 of /home/shackle/pggit/postgresql/contrib/pg_trgm/trgm_gist.c
- Starting at line 728 of /home/shackle/pggit/postgresql/src/backend/utils/adt/tsgistidx.c
- costvector[j - 1].cost = abs(size_alpha - size_beta);
- }
- qsort((void *) costvector, maxoff, sizeof(SPLITCOST), comparecost);
- for (k = 0; k < maxoff; k++)
- {
- j = costvector[k].pos;
- if (j == seed_1)
- {
- *left++ = j;
- v->spl_nleft++;
- continue;
- }
- else if (j == seed_2)
- {
- *right++ = j;
- v->spl_nright++;
- continue;
- }
- if (ISALLTRUE(datum_l) || cache[j].allistrue)
- {
- if (ISALLTRUE(datum_l) && cache[j].allistrue)
- size_alpha = 0;
- else
- size_alpha = SIGLENBIT - sizebitvec(
- (cache[j].allistrue) ? GETSIGN(datum_l) : GETSIGN(cache[j].sign)
- );
- }
- else
- size_alpha = hemdistsign(cache[j].sign, GETSIGN(datum_l));
- if (ISALLTRUE(datum_r) || cache[j].allistrue)
- {
- if (ISALLTRUE(datum_r) && cache[j].allistrue)
- size_beta = 0;
- else
- size_beta = SIGLENBIT - sizebitvec(
- (cache[j].allistrue) ? GETSIGN(datum_r) : GETSIGN(cache[j].sign)
- );
- }
- else
- size_beta = hemdistsign(cache[j].sign, GETSIGN(datum_r));
- if (size_alpha < size_beta + WISH_F(v->spl_nleft, v->spl_nright, 0.1))
- {
- if (ISALLTRUE(datum_l) || cache[j].allistrue)
- {
- if (!ISALLTRUE(datum_l))
- MemSet((void *) GETSIGN(datum_l), 0xff, sizeof(BITVEC));
- }
- else
- {
- ptr = cache[j].sign;
- LOOPBYTE
- union_l[i] |= ptr[i];
- }
- *left++ = j;
- v->spl_nleft++;
- }
- else
- {
- if (ISALLTRUE(datum_r) || cache[j].allistrue)
- {
- if (!ISALLTRUE(datum_r))
- MemSet((void *) GETSIGN(datum_r), 0xff, sizeof(BITVEC));
- }
- else
- {
- ptr = cache[j].sign;
- LOOPBYTE
- union_r[i] |= ptr[i];
- }
- *right++ = j;
- v->spl_nright++;
- }
- }
- *right = *left = FirstOffsetNumber;
- v->spl_ldatum = PointerGetDatum(datum_l);
- v->spl_rdatum = PointerGetDatum(datum_r);
- PG_RETURN_POINTER(v);
- }
- =====================================================================
- Found a 37 line (467 tokens) duplication in the following files:
- Starting at line 194 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/compat_informix-rnull.c
- Starting at line 234 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/compat_informix-rnull.c
- { 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,
- ECPGt_char,(c),(long)sizeof("abc"),(long)1,(sizeof("abc"))*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_short,&(s),(long)1,(long)1,sizeof(short),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_int,&(i),(long)1,(long)1,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_bool,&(b),(long)1,(long)1,sizeof(bool),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_float,&(f),(long)1,(long)1,sizeof(float),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_long,&(l),(long)1,(long)1,sizeof(long),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_double,&(dbl),(long)1,(long)1,sizeof(double),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_decimal,&(dec),(long)1,(long)1,sizeof(decimal),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_date,&(dat),(long)1,(long)1,sizeof(date),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_timestamp,&(tmp),(long)1,(long)1,sizeof(timestamp),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
- #line 61 "rnull.pgc"
- if (sqlca.sqlcode < 0) sqlprint ( );}
- #line 61 "rnull.pgc"
- test_null(CCHARTYPE, (char *) c);
- test_null(CSHORTTYPE, (char *) &s);
- test_null(CINTTYPE, (char *) &i);
- test_null(CBOOLTYPE, (char *) &b);
- test_null(CFLOATTYPE, (char *) &f);
- test_null(CLONGTYPE, (char *) &l);
- test_null(CDOUBLETYPE, (char *) &dbl);
- test_null(CDECIMALTYPE, (char *) &dec);
- test_null(CDATETYPE, (char *) &dat);
- test_null(CDTIMETYPE, (char *) &tmp);
- =====================================================================
- Found a 71 line (456 tokens) duplication in the following files:
- Starting at line 360 of /home/shackle/pggit/postgresql/contrib/hstore/hstore_gist.c
- Starting at line 354 of /home/shackle/pggit/postgresql/contrib/intarray/_intbig_gist.c
- *_j;
- nbytes = (maxoff + 2) * sizeof(OffsetNumber);
- v->spl_left = (OffsetNumber *) palloc(nbytes);
- v->spl_right = (OffsetNumber *) palloc(nbytes);
- for (k = FirstOffsetNumber; k < maxoff; k = OffsetNumberNext(k))
- {
- _k = GETENTRY(entryvec, k);
- for (j = OffsetNumberNext(k); j <= maxoff; j = OffsetNumberNext(j))
- {
- size_waste = hemdist(_k, GETENTRY(entryvec, j));
- if (size_waste > waste)
- {
- waste = size_waste;
- seed_1 = k;
- seed_2 = j;
- }
- }
- }
- left = v->spl_left;
- v->spl_nleft = 0;
- right = v->spl_right;
- v->spl_nright = 0;
- if (seed_1 == 0 || seed_2 == 0)
- {
- seed_1 = 1;
- seed_2 = 2;
- }
- /* form initial .. */
- if (ISALLTRUE(GETENTRY(entryvec, seed_1)))
- {
- datum_l = (GISTTYPE *) palloc(GTHDRSIZE);
- SET_VARSIZE(datum_l, GTHDRSIZE);
- datum_l->flag = ALLISTRUE;
- }
- else
- {
- datum_l = (GISTTYPE *) palloc(GTHDRSIZE + SIGLEN);
- SET_VARSIZE(datum_l, GTHDRSIZE + SIGLEN);
- datum_l->flag = 0;
- memcpy((void *) GETSIGN(datum_l), (void *) GETSIGN(GETENTRY(entryvec, seed_1)), sizeof(BITVEC))
- ;
- }
- if (ISALLTRUE(GETENTRY(entryvec, seed_2)))
- {
- datum_r = (GISTTYPE *) palloc(GTHDRSIZE);
- SET_VARSIZE(datum_r, GTHDRSIZE);
- datum_r->flag = ALLISTRUE;
- }
- else
- {
- datum_r = (GISTTYPE *) palloc(GTHDRSIZE + SIGLEN);
- SET_VARSIZE(datum_r, GTHDRSIZE + SIGLEN);
- datum_r->flag = 0;
- memcpy((void *) GETSIGN(datum_r), (void *) GETSIGN(GETENTRY(entryvec, seed_2)), sizeof(BITVEC));
- }
- maxoff = OffsetNumberNext(maxoff);
- /* sort before ... */
- costvector = (SPLITCOST *) palloc(sizeof(SPLITCOST) * maxoff);
- for (j = FirstOffsetNumber; j <= maxoff; j = OffsetNumberNext(j))
- {
- costvector[j - 1].pos = j;
- _j = GETENTRY(entryvec, j);
- size_alpha = hemdist(datum_l, _j);
- size_beta = hemdist(datum_r, _j);
- costvector[j - 1].cost = abs(size_alpha - size_beta);
- =====================================================================
- Found a 101 line (456 tokens) duplication in the following files:
- Starting at line 3570 of /home/shackle/pggit/postgresql/src/backend/utils/adt/timestamp.c
- Starting at line 3691 of /home/shackle/pggit/postgresql/src/backend/utils/adt/timestamp.c
- timestamp2tm(dt2, NULL, tm2, &fsec2, NULL, NULL) == 0)
- {
- /* form the symbolic difference */
- fsec = fsec1 - fsec2;
- tm->tm_sec = tm1->tm_sec - tm2->tm_sec;
- tm->tm_min = tm1->tm_min - tm2->tm_min;
- tm->tm_hour = tm1->tm_hour - tm2->tm_hour;
- tm->tm_mday = tm1->tm_mday - tm2->tm_mday;
- tm->tm_mon = tm1->tm_mon - tm2->tm_mon;
- tm->tm_year = tm1->tm_year - tm2->tm_year;
- /* flip sign if necessary... */
- if (dt1 < dt2)
- {
- fsec = -fsec;
- tm->tm_sec = -tm->tm_sec;
- tm->tm_min = -tm->tm_min;
- tm->tm_hour = -tm->tm_hour;
- tm->tm_mday = -tm->tm_mday;
- tm->tm_mon = -tm->tm_mon;
- tm->tm_year = -tm->tm_year;
- }
- /* propagate any negative fields into the next higher field */
- while (fsec < 0)
- {
- fsec += USECS_PER_SEC;
- tm->tm_sec--;
- }
- while (tm->tm_sec < 0)
- {
- tm->tm_sec += SECS_PER_MINUTE;
- tm->tm_min--;
- }
- while (tm->tm_min < 0)
- {
- tm->tm_min += MINS_PER_HOUR;
- tm->tm_hour--;
- }
- while (tm->tm_hour < 0)
- {
- tm->tm_hour += HOURS_PER_DAY;
- tm->tm_mday--;
- }
- while (tm->tm_mday < 0)
- {
- if (dt1 < dt2)
- {
- tm->tm_mday += day_tab[isleap(tm1->tm_year)][tm1->tm_mon - 1];
- tm->tm_mon--;
- }
- else
- {
- tm->tm_mday += day_tab[isleap(tm2->tm_year)][tm2->tm_mon - 1];
- tm->tm_mon--;
- }
- }
- while (tm->tm_mon < 0)
- {
- tm->tm_mon += MONTHS_PER_YEAR;
- tm->tm_year--;
- }
- /* recover sign if necessary... */
- if (dt1 < dt2)
- {
- fsec = -fsec;
- tm->tm_sec = -tm->tm_sec;
- tm->tm_min = -tm->tm_min;
- tm->tm_hour = -tm->tm_hour;
- tm->tm_mday = -tm->tm_mday;
- tm->tm_mon = -tm->tm_mon;
- tm->tm_year = -tm->tm_year;
- }
- if (tm2interval(tm, fsec, result) != 0)
- ereport(ERROR,
- (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
- errmsg("interval out of range")));
- }
- else
- ereport(ERROR,
- (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
- errmsg("timestamp out of range")));
- PG_RETURN_INTERVAL_P(result);
- }
- /* timestamptz_age()
- * Calculate time difference while retaining year/month fields.
- * Note that this does not result in an accurate absolute time span
- * since year and month are out of context once the arithmetic
- * is done.
- */
- Datum
- =====================================================================
- Found a 116 line (443 tokens) duplication in the following files:
- Starting at line 984 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
- Starting at line 1891 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
- errno = 0;
- val = strtoint(field[i], &cp, 10);
- if (errno == ERANGE)
- return DTERR_FIELD_OVERFLOW;
- /*
- * only a few kinds are allowed to have an embedded
- * decimal
- */
- if (*cp == '.')
- switch (ptype)
- {
- case DTK_JULIAN:
- case DTK_TIME:
- case DTK_SECOND:
- break;
- default:
- return DTERR_BAD_FORMAT;
- break;
- }
- else if (*cp != '\0')
- return DTERR_BAD_FORMAT;
- switch (ptype)
- {
- case DTK_YEAR:
- tm->tm_year = val;
- tmask = DTK_M(YEAR);
- break;
- case DTK_MONTH:
- /*
- * already have a month and hour? then assume
- * minutes
- */
- if ((fmask & DTK_M(MONTH)) != 0 &&
- (fmask & DTK_M(HOUR)) != 0)
- {
- tm->tm_min = val;
- tmask = DTK_M(MINUTE);
- }
- else
- {
- tm->tm_mon = val;
- tmask = DTK_M(MONTH);
- }
- break;
- case DTK_DAY:
- tm->tm_mday = val;
- tmask = DTK_M(DAY);
- break;
- case DTK_HOUR:
- tm->tm_hour = val;
- tmask = DTK_M(HOUR);
- break;
- case DTK_MINUTE:
- tm->tm_min = val;
- tmask = DTK_M(MINUTE);
- break;
- case DTK_SECOND:
- tm->tm_sec = val;
- tmask = DTK_M(SECOND);
- if (*cp == '.')
- {
- dterr = ParseFractionalSecond(cp, fsec);
- if (dterr)
- return dterr;
- tmask = DTK_ALL_SECS_M;
- }
- break;
- case DTK_TZ:
- tmask = DTK_M(TZ);
- dterr = DecodeTimezone(field[i], tzp);
- if (dterr)
- return dterr;
- break;
- case DTK_JULIAN:
- /* previous field was a label for "julian date" */
- if (val < 0)
- return DTERR_FIELD_OVERFLOW;
- tmask = DTK_DATE_M;
- j2date(val, &tm->tm_year, &tm->tm_mon, &tm->tm_mday);
- isjulian = true;
- /* fractional Julian Day? */
- if (*cp == '.')
- {
- double time;
- errno = 0;
- time = strtod(cp, &cp);
- if (*cp != '\0' || errno != 0)
- return DTERR_BAD_FORMAT;
- time *= USECS_PER_DAY;
- dt2time(time,
- &tm->tm_hour, &tm->tm_min,
- &tm->tm_sec, fsec);
- tmask |= DTK_TIME_M;
- }
- break;
- case DTK_TIME:
- /* previous field was "t" for ISO time */
- dterr = DecodeNumberField(strlen(field[i]), field[i],
- (fmask | DTK_DATE_M),
- &tmask, tm,
- fsec, &is2digits);
- if (dterr < 0)
- return dterr;
- =====================================================================
- Found a 130 line (420 tokens) duplication in the following files:
- Starting at line 554 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/interval.c
- Starting at line 3317 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
- tmask = (fmask & DTK_M(YEAR)) ? 0 : DTK_M(YEAR);
- break;
- default:
- return DTERR_BAD_FORMAT;
- }
- break;
- case DTK_STRING:
- case DTK_SPECIAL:
- type = DecodeUnits(i, field[i], &val);
- if (type == IGNORE_DTF)
- continue;
- tmask = 0; /* DTK_M(type); */
- switch (type)
- {
- case UNITS:
- type = val;
- break;
- case AGO:
- is_before = true;
- type = val;
- break;
- case RESERV:
- tmask = (DTK_DATE_M | DTK_TIME_M);
- *dtype = val;
- break;
- default:
- return DTERR_BAD_FORMAT;
- }
- break;
- default:
- return DTERR_BAD_FORMAT;
- }
- if (tmask & fmask)
- return DTERR_BAD_FORMAT;
- fmask |= tmask;
- }
- /* ensure that at least one time field has been found */
- if (fmask == 0)
- return DTERR_BAD_FORMAT;
- /* ensure fractional seconds are fractional */
- if (*fsec != 0)
- {
- int sec;
- sec = *fsec / USECS_PER_SEC;
- *fsec -= sec * USECS_PER_SEC;
- tm->tm_sec += sec;
- }
- /*----------
- * The SQL standard defines the interval literal
- * '-1 1:00:00'
- * to mean "negative 1 days and negative 1 hours", while Postgres
- * traditionally treats this as meaning "negative 1 days and positive
- * 1 hours". In SQL_STANDARD intervalstyle, we apply the leading sign
- * to all fields if there are no other explicit signs.
- *
- * We leave the signs alone if there are additional explicit signs.
- * This protects us against misinterpreting postgres-style dump output,
- * since the postgres-style output code has always put an explicit sign on
- * all fields following a negative field. But note that SQL-spec output
- * is ambiguous and can be misinterpreted on load! (So it's best practice
- * to dump in postgres style, not SQL style.)
- *----------
- */
- if (IntervalStyle == INTSTYLE_SQL_STANDARD && *field[0] == '-')
- {
- /* Check for additional explicit signs */
- bool more_signs = false;
- for (i = 1; i < nf; i++)
- {
- if (*field[i] == '-' || *field[i] == '+')
- {
- more_signs = true;
- break;
- }
- }
- if (!more_signs)
- {
- /*
- * Rather than re-determining which field was field[0], just force
- * 'em all negative.
- */
- if (*fsec > 0)
- *fsec = -(*fsec);
- if (tm->tm_sec > 0)
- tm->tm_sec = -tm->tm_sec;
- if (tm->tm_min > 0)
- tm->tm_min = -tm->tm_min;
- if (tm->tm_hour > 0)
- tm->tm_hour = -tm->tm_hour;
- if (tm->tm_mday > 0)
- tm->tm_mday = -tm->tm_mday;
- if (tm->tm_mon > 0)
- tm->tm_mon = -tm->tm_mon;
- if (tm->tm_year > 0)
- tm->tm_year = -tm->tm_year;
- }
- }
- /* finally, AGO negates everything */
- if (is_before)
- {
- *fsec = -(*fsec);
- tm->tm_sec = -tm->tm_sec;
- tm->tm_min = -tm->tm_min;
- tm->tm_hour = -tm->tm_hour;
- tm->tm_mday = -tm->tm_mday;
- tm->tm_mon = -tm->tm_mon;
- tm->tm_year = -tm->tm_year;
- }
- return 0;
- }
- /* copy&pasted from .../src/backend/utils/adt/datetime.c */
- static char *
- =====================================================================
- Found a 73 line (408 tokens) duplication in the following files:
- Starting at line 809 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
- Starting at line 1051 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
- Starting at line 1314 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
- Starting at line 1558 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
- check_stack_depth(); /* recurses for record-type columns */
- /* Extract type info from the tuples */
- tupType1 = HeapTupleHeaderGetTypeId(record1);
- tupTypmod1 = HeapTupleHeaderGetTypMod(record1);
- tupdesc1 = lookup_rowtype_tupdesc(tupType1, tupTypmod1);
- ncolumns1 = tupdesc1->natts;
- tupType2 = HeapTupleHeaderGetTypeId(record2);
- tupTypmod2 = HeapTupleHeaderGetTypMod(record2);
- tupdesc2 = lookup_rowtype_tupdesc(tupType2, tupTypmod2);
- ncolumns2 = tupdesc2->natts;
- /* Build temporary HeapTuple control structures */
- tuple1.t_len = HeapTupleHeaderGetDatumLength(record1);
- ItemPointerSetInvalid(&(tuple1.t_self));
- tuple1.t_tableOid = InvalidOid;
- tuple1.t_data = record1;
- tuple2.t_len = HeapTupleHeaderGetDatumLength(record2);
- ItemPointerSetInvalid(&(tuple2.t_self));
- tuple2.t_tableOid = InvalidOid;
- tuple2.t_data = record2;
- /*
- * We arrange to look up the needed comparison info just once per series
- * of calls, assuming the record types don't change underneath us.
- */
- ncols = Max(ncolumns1, ncolumns2);
- my_extra = (RecordCompareData *) fcinfo->flinfo->fn_extra;
- if (my_extra == NULL ||
- my_extra->ncolumns < ncols)
- {
- fcinfo->flinfo->fn_extra =
- MemoryContextAlloc(fcinfo->flinfo->fn_mcxt,
- offsetof(RecordCompareData, columns) +
- ncols * sizeof(ColumnCompareData));
- my_extra = (RecordCompareData *) fcinfo->flinfo->fn_extra;
- my_extra->ncolumns = ncols;
- my_extra->record1_type = InvalidOid;
- my_extra->record1_typmod = 0;
- my_extra->record2_type = InvalidOid;
- my_extra->record2_typmod = 0;
- }
- if (my_extra->record1_type != tupType1 ||
- my_extra->record1_typmod != tupTypmod1 ||
- my_extra->record2_type != tupType2 ||
- my_extra->record2_typmod != tupTypmod2)
- {
- MemSet(my_extra->columns, 0, ncols * sizeof(ColumnCompareData));
- my_extra->record1_type = tupType1;
- my_extra->record1_typmod = tupTypmod1;
- my_extra->record2_type = tupType2;
- my_extra->record2_typmod = tupTypmod2;
- }
- /* Break down the tuples into fields */
- values1 = (Datum *) palloc(ncolumns1 * sizeof(Datum));
- nulls1 = (bool *) palloc(ncolumns1 * sizeof(bool));
- heap_deform_tuple(&tuple1, tupdesc1, values1, nulls1);
- values2 = (Datum *) palloc(ncolumns2 * sizeof(Datum));
- nulls2 = (bool *) palloc(ncolumns2 * sizeof(bool));
- heap_deform_tuple(&tuple2, tupdesc2, values2, nulls2);
- /*
- * Scan corresponding columns, allowing for dropped columns in different
- * places in the two rows. i1 and i2 are physical column indexes, j is
- * the logical column index.
- */
- i1 = i2 = j = 0;
- while (i1 < ncolumns1 || i2 < ncolumns2)
- {
- Form_pg_attribute att1;
- Form_pg_attribute att2;
- =====================================================================
- Found a 18 line (397 tokens) duplication in the following files:
- Starting at line 206 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-outofscope.c
- Starting at line 230 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-outofscope.c
- { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare mycur cursor for select * from a1", ECPGt_EOIT,
- ECPGt_int,&((*( MYTYPE *)(ECPGget_var( 0)) ).id),(long)1,(long)1,sizeof( struct mytype ),
- ECPGt_int,&((*( MYNULLTYPE *)(ECPGget_var( 1)) ).id),(long)1,(long)1,sizeof( struct mynulltype ),
- ECPGt_char,&((*( MYTYPE *)(ECPGget_var( 0)) ).t),(long)64,(long)1,sizeof( struct mytype ),
- ECPGt_int,&((*( MYNULLTYPE *)(ECPGget_var( 1)) ).t),(long)1,(long)1,sizeof( struct mynulltype ),
- ECPGt_double,&((*( MYTYPE *)(ECPGget_var( 0)) ).d1),(long)1,(long)1,sizeof( struct mytype ),
- ECPGt_int,&((*( MYNULLTYPE *)(ECPGget_var( 1)) ).d1),(long)1,(long)1,sizeof( struct mynulltype ),
- ECPGt_double,&((*( MYTYPE *)(ECPGget_var( 0)) ).d2),(long)1,(long)1,sizeof( struct mytype ),
- ECPGt_int,&((*( MYNULLTYPE *)(ECPGget_var( 1)) ).d2),(long)1,(long)1,sizeof( struct mynulltype ),
- ECPGt_char,&((*( MYTYPE *)(ECPGget_var( 0)) ).c),(long)30,(long)1,sizeof( struct mytype ),
- ECPGt_int,&((*( MYNULLTYPE *)(ECPGget_var( 1)) ).c),(long)1,(long)1,sizeof( struct mynulltype ), ECPGt_EORT);
- #line 40 "outofscope.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 40 "outofscope.pgc"
- if (sqlca.sqlcode != 0)
- =====================================================================
- Found a 86 line (388 tokens) duplication in the following files:
- Starting at line 197 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/compat_informix-describe.c
- Starting at line 195 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-describe.c
- { ECPGdescribe(__LINE__, 1, 0, NULL, "st_id1",
- ECPGt_sqlda, &sqlda3, 0L, 0L, 0L,
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
- #line 65 "describe.pgc"
- if (sqlda1 == NULL)
- {
- printf("sqlda1 NULL\n");
- exit(1);
- }
- if (sqlda2 == NULL)
- {
- printf("sqlda2 NULL\n");
- exit(1);
- }
- if (sqlda3 == NULL)
- {
- printf("sqlda3 NULL\n");
- exit(1);
- }
- strcpy(msg, "get descriptor");
- { ECPGget_desc_header(__LINE__, "desc1", &(count1));
- #line 86 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 86 "describe.pgc"
- { ECPGget_desc_header(__LINE__, "desc1", &(count2));
- #line 87 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 87 "describe.pgc"
- if (count1 != count2)
- {
- printf("count1 (%d) != count2 (%d)\n", count1, count2);
- exit(1);
- }
- if (count1 != sqlda1->sqld)
- {
- printf("count1 (%d) != sqlda1->sqld (%d)\n", count1, sqlda1->sqld);
- exit(1);
- }
- if (count1 != sqlda2->sqld)
- {
- printf("count1 (%d) != sqlda2->sqld (%d)\n", count1, sqlda2->sqld);
- exit(1);
- }
- if (count1 != sqlda3->sqld)
- {
- printf("count1 (%d) != sqlda3->sqld (%d)\n", count1, sqlda3->sqld);
- exit(1);
- }
- for (i = 1; i <= count1; i++)
- {
- { ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
- ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
- #line 115 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 115 "describe.pgc"
- { ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
- ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
- #line 116 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 116 "describe.pgc"
- printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
- "sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n",
- i, field_name1, field_name2,
- sqlda1->sqlvar[i-1].sqlname,
- =====================================================================
- Found a 16 line (385 tokens) duplication in the following files:
- Starting at line 3556 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
- Starting at line 104 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- return PQescapeInternal(conn, str, len, true);
- }
- /* HEX encoding support for bytea */
- static const char hextbl[] = "0123456789abcdef";
- static const int8 hexlookup[128] = {
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1,
- -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- };
- =====================================================================
- Found a 73 line (374 tokens) duplication in the following files:
- Starting at line 763 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/interval.c
- Starting at line 4229 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
- EncodeInterval(struct /* pg_ */ tm *tm, fsec_t fsec, int style, char *str)
- {
- char *cp = str;
- int year = tm->tm_year;
- int mon = tm->tm_mon;
- int mday = tm->tm_mday;
- int hour = tm->tm_hour;
- int min = tm->tm_min;
- int sec = tm->tm_sec;
- bool is_before = false;
- bool is_zero = true;
- /*
- * The sign of year and month are guaranteed to match, since they are
- * stored internally as "month". But we'll need to check for is_before and
- * is_zero when determining the signs of day and hour/minute/seconds
- * fields.
- */
- switch (style)
- {
- /* SQL Standard interval format */
- case INTSTYLE_SQL_STANDARD:
- {
- bool has_negative = year < 0 || mon < 0 ||
- mday < 0 || hour < 0 ||
- min < 0 || sec < 0 || fsec < 0;
- bool has_positive = year > 0 || mon > 0 ||
- mday > 0 || hour > 0 ||
- min > 0 || sec > 0 || fsec > 0;
- bool has_year_month = year != 0 || mon != 0;
- bool has_day_time = mday != 0 || hour != 0 ||
- min != 0 || sec != 0 || fsec != 0;
- bool has_day = mday != 0;
- bool sql_standard_value = !(has_negative && has_positive) &&
- !(has_year_month && has_day_time);
- /*
- * SQL Standard wants only 1 "<sign>" preceding the whole
- * interval ... but can't do that if mixed signs.
- */
- if (has_negative && sql_standard_value)
- {
- *cp++ = '-';
- year = -year;
- mon = -mon;
- mday = -mday;
- hour = -hour;
- min = -min;
- sec = -sec;
- fsec = -fsec;
- }
- if (!has_negative && !has_positive)
- {
- sprintf(cp, "0");
- }
- else if (!sql_standard_value)
- {
- /*
- * For non sql-standard interval values, force outputting
- * the signs to avoid ambiguities with intervals with
- * mixed sign components.
- */
- char year_sign = (year < 0 || mon < 0) ? '-' : '+';
- char day_sign = (mday < 0) ? '-' : '+';
- char sec_sign = (hour < 0 || min < 0 ||
- sec < 0 || fsec < 0) ? '-' : '+';
- sprintf(cp, "%c%d-%d %c%d %c%d:%02d:",
- year_sign, abs(year), abs(mon),
- day_sign, abs(mday),
- sec_sign, abs(hour), abs(min));
- cp += strlen(cp);
- =====================================================================
- Found a 12 line (372 tokens) duplication in the following files:
- Starting at line 3562 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
- Starting at line 40 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
- static const int8 hexlookup[128] = {
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1,
- -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- };
- static inline char
- =====================================================================
- Found a 10 line (370 tokens) duplication in the following files:
- Starting at line 114 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 40 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
- static const int8 hexlookup[128] = {
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1,
- -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- };
- =====================================================================
- Found a 13 line (340 tokens) duplication in the following files:
- Starting at line 27 of /home/shackle/pggit/postgresql/src/common/base64.c
- Starting at line 203 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- static const char _base64[] =
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
- static const int8 b64lookup[128] = {
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
- 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1,
- -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
- 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
- -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
- 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1,
- };
- =====================================================================
- Found a 21 line (330 tokens) duplication in the following files:
- Starting at line 159 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/compat_informix-rnull.c
- Starting at line 194 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/compat_informix-rnull.c
- Starting at line 234 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/compat_informix-rnull.c
- { 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 )",
- ECPGt_char,(c),(long)sizeof("abc"),(long)1,(sizeof("abc"))*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_short,&(s),(long)1,(long)1,sizeof(short),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_int,&(i),(long)1,(long)1,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_bool,&(b),(long)1,(long)1,sizeof(bool),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_float,&(f),(long)1,(long)1,sizeof(float),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_long,&(l),(long)1,(long)1,sizeof(long),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_double,&(dbl),(long)1,(long)1,sizeof(double),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_decimal,&(dec),(long)1,(long)1,sizeof(decimal),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_date,&(dat),(long)1,(long)1,sizeof(date),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_timestamp,&(tmp),(long)1,(long)1,sizeof(timestamp),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
- =====================================================================
- Found a 56 line (300 tokens) duplication in the following files:
- Starting at line 10205 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_dump.c
- Starting at line 10560 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_dump.c
- appendPQExpBuffer(q, ",\n subtype_diff = %s", procname);
- appendPQExpBufferStr(q, "\n);\n");
- if (dopt->binary_upgrade)
- binary_upgrade_extension_member(q, &tyinfo->dobj,
- "TYPE", qtypname,
- tyinfo->dobj.namespace->dobj.name);
- if (tyinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
- ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId,
- tyinfo->dobj.name,
- tyinfo->dobj.namespace->dobj.name,
- NULL,
- tyinfo->rolname,
- "TYPE", SECTION_PRE_DATA,
- q->data, delq->data, NULL,
- NULL, 0,
- NULL, NULL);
- /* Dump Type Comments and Security Labels */
- if (tyinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
- dumpComment(fout, "TYPE", qtypname,
- tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
- tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
- if (tyinfo->dobj.dump & DUMP_COMPONENT_SECLABEL)
- dumpSecLabel(fout, "TYPE", qtypname,
- tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
- tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
- if (tyinfo->dobj.dump & DUMP_COMPONENT_ACL)
- dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
- qtypname, NULL,
- tyinfo->dobj.namespace->dobj.name,
- tyinfo->rolname, tyinfo->typacl, tyinfo->rtypacl,
- tyinfo->inittypacl, tyinfo->initrtypacl);
- PQclear(res);
- destroyPQExpBuffer(q);
- destroyPQExpBuffer(delq);
- destroyPQExpBuffer(query);
- free(qtypname);
- free(qualtypname);
- }
- /*
- * dumpUndefinedType
- * writes out to fout the queries to recreate a !typisdefined type
- *
- * This is a shell type, but we use different terminology to distinguish
- * this case from where we have to emit a shell type definition to break
- * circular dependencies. An undefined type shouldn't ever have anything
- * depending on it.
- */
- static void
- =====================================================================
- Found a 47 line (291 tokens) duplication in the following files:
- Starting at line 10082 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_dump.c
- Starting at line 10209 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_dump.c
- Starting at line 10564 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_dump.c
- if (dopt->binary_upgrade)
- binary_upgrade_extension_member(q, &tyinfo->dobj,
- "TYPE", qtypname,
- tyinfo->dobj.namespace->dobj.name);
- if (tyinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
- ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId,
- tyinfo->dobj.name,
- tyinfo->dobj.namespace->dobj.name,
- NULL,
- tyinfo->rolname,
- "TYPE", SECTION_PRE_DATA,
- q->data, delq->data, NULL,
- NULL, 0,
- NULL, NULL);
- /* Dump Type Comments and Security Labels */
- if (tyinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
- dumpComment(fout, "TYPE", qtypname,
- tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
- tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
- if (tyinfo->dobj.dump & DUMP_COMPONENT_SECLABEL)
- dumpSecLabel(fout, "TYPE", qtypname,
- tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
- tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
- if (tyinfo->dobj.dump & DUMP_COMPONENT_ACL)
- dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
- qtypname, NULL,
- tyinfo->dobj.namespace->dobj.name,
- tyinfo->rolname, tyinfo->typacl, tyinfo->rtypacl,
- tyinfo->inittypacl, tyinfo->initrtypacl);
- PQclear(res);
- destroyPQExpBuffer(q);
- destroyPQExpBuffer(delq);
- destroyPQExpBuffer(query);
- free(qtypname);
- free(qualtypname);
- }
- /*
- * dumpRangeType
- * writes out to fout the queries to recreate a user-defined range type
- */
- static void
- =====================================================================
- Found a 81 line (286 tokens) duplication in the following files:
- Starting at line 181 of /home/shackle/pggit/postgresql/src/backend/utils/time/tqual.c
- Starting at line 748 of /home/shackle/pggit/postgresql/src/backend/utils/time/tqual.c
- Assert(htup->t_tableOid != InvalidOid);
- if (!HeapTupleHeaderXminCommitted(tuple))
- {
- if (HeapTupleHeaderXminInvalid(tuple))
- return false;
- /* Used by pre-9.0 binary upgrades */
- if (tuple->t_infomask & HEAP_MOVED_OFF)
- {
- TransactionId xvac = HeapTupleHeaderGetXvac(tuple);
- if (TransactionIdIsCurrentTransactionId(xvac))
- return false;
- if (!TransactionIdIsInProgress(xvac))
- {
- if (TransactionIdDidCommit(xvac))
- {
- SetHintBits(tuple, buffer, HEAP_XMIN_INVALID,
- InvalidTransactionId);
- return false;
- }
- SetHintBits(tuple, buffer, HEAP_XMIN_COMMITTED,
- InvalidTransactionId);
- }
- }
- /* Used by pre-9.0 binary upgrades */
- else if (tuple->t_infomask & HEAP_MOVED_IN)
- {
- TransactionId xvac = HeapTupleHeaderGetXvac(tuple);
- if (!TransactionIdIsCurrentTransactionId(xvac))
- {
- if (TransactionIdIsInProgress(xvac))
- return false;
- if (TransactionIdDidCommit(xvac))
- SetHintBits(tuple, buffer, HEAP_XMIN_COMMITTED,
- InvalidTransactionId);
- else
- {
- SetHintBits(tuple, buffer, HEAP_XMIN_INVALID,
- InvalidTransactionId);
- return false;
- }
- }
- }
- else if (TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetRawXmin(tuple)))
- {
- if (tuple->t_infomask & HEAP_XMAX_INVALID) /* xid invalid */
- return true;
- if (HEAP_XMAX_IS_LOCKED_ONLY(tuple->t_infomask)) /* not deleter */
- return true;
- if (tuple->t_infomask & HEAP_XMAX_IS_MULTI)
- {
- TransactionId xmax;
- xmax = HeapTupleGetUpdateXid(tuple);
- /* not LOCKED_ONLY, so it has to have an xmax */
- Assert(TransactionIdIsValid(xmax));
- /* updating subtransaction must have aborted */
- if (!TransactionIdIsCurrentTransactionId(xmax))
- return true;
- else
- return false;
- }
- if (!TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetRawXmax(tuple)))
- {
- /* deleting subtransaction must have aborted */
- SetHintBits(tuple, buffer, HEAP_XMAX_INVALID,
- InvalidTransactionId);
- return true;
- }
- return false;
- }
- else if (TransactionIdIsInProgress(HeapTupleHeaderGetRawXmin(tuple)))
- =====================================================================
- Found a 53 line (285 tokens) duplication in the following files:
- Starting at line 359 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/compat_informix-describe.c
- Starting at line 357 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-describe.c
- { ECPGdescribe(__LINE__, 1, 0, NULL, "st_id2",
- ECPGt_sqlda, &sqlda3, 0L, 0L, 0L,
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
- #line 151 "describe.pgc"
- if (sqlda1 == NULL || sqlda2 == NULL || sqlda3 == NULL)
- exit(1);
- strcpy(msg, "get descriptor");
- { ECPGget_desc_header(__LINE__, "desc1", &(count1));
- #line 157 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 157 "describe.pgc"
- { ECPGget_desc_header(__LINE__, "desc1", &(count2));
- #line 158 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 158 "describe.pgc"
- if (!( count1 == count2 &&
- count1 == sqlda1->sqld &&
- count1 == sqlda2->sqld &&
- count1 == sqlda3->sqld))
- exit(1);
- for (i = 1; i <= count1; i++)
- {
- { ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
- ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
- #line 168 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 168 "describe.pgc"
- { ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
- ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
- #line 169 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 169 "describe.pgc"
- printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
- "sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n",
- i, field_name1, field_name2,
- sqlda1->sqlvar[i-1].sqlname,
- =====================================================================
- Found a 61 line (281 tokens) duplication in the following files:
- Starting at line 34 of /home/shackle/pggit/postgresql/src/backend/access/gin/ginvalidate.c
- Starting at line 34 of /home/shackle/pggit/postgresql/src/backend/access/gist/gistvalidate.c
- ginvalidate(Oid opclassoid)
- {
- bool result = true;
- HeapTuple classtup;
- Form_pg_opclass classform;
- Oid opfamilyoid;
- Oid opcintype;
- Oid opckeytype;
- char *opclassname;
- HeapTuple familytup;
- Form_pg_opfamily familyform;
- char *opfamilyname;
- CatCList *proclist,
- *oprlist;
- List *grouplist;
- OpFamilyOpFuncGroup *opclassgroup;
- int i;
- ListCell *lc;
- /* Fetch opclass information */
- classtup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclassoid));
- if (!HeapTupleIsValid(classtup))
- elog(ERROR, "cache lookup failed for operator class %u", opclassoid);
- classform = (Form_pg_opclass) GETSTRUCT(classtup);
- opfamilyoid = classform->opcfamily;
- opcintype = classform->opcintype;
- opckeytype = classform->opckeytype;
- if (!OidIsValid(opckeytype))
- opckeytype = opcintype;
- opclassname = NameStr(classform->opcname);
- /* Fetch opfamily information */
- familytup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfamilyoid));
- if (!HeapTupleIsValid(familytup))
- elog(ERROR, "cache lookup failed for operator family %u", opfamilyoid);
- familyform = (Form_pg_opfamily) GETSTRUCT(familytup);
- opfamilyname = NameStr(familyform->opfname);
- /* Fetch all operators and support functions of the opfamily */
- oprlist = SearchSysCacheList1(AMOPSTRATEGY, ObjectIdGetDatum(opfamilyoid));
- proclist = SearchSysCacheList1(AMPROCNUM, ObjectIdGetDatum(opfamilyoid));
- /* Check individual support functions */
- for (i = 0; i < proclist->n_members; i++)
- {
- HeapTuple proctup = &proclist->members[i]->tuple;
- Form_pg_amproc procform = (Form_pg_amproc) GETSTRUCT(proctup);
- bool ok;
- /*
- * All GIN support functions should be registered with matching
- * left/right types
- */
- if (procform->amproclefttype != procform->amprocrighttype)
- {
- ereport(INFO,
- (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
- errmsg("operator family \"%s\" of access method %s contains support function %s with different left and right input types",
- opfamilyname, "gin",
- =====================================================================
- Found a 53 line (279 tokens) duplication in the following files:
- Starting at line 117 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-array_of_struct.c
- Starting at line 121 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-pointer_to_struct.c
- struct varchar_5 { int len; char arr[ 50 ]; } onlyname [ 2 ] ;
- /* exec sql end declare section */
- #line 46 "array_of_struct.pgc"
- ECPGdebug(1, stderr);
- { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0);
- #line 50 "array_of_struct.pgc"
- if (sqlca.sqlwarn[0] == 'W') sqlprint();
- #line 50 "array_of_struct.pgc"
- if (sqlca.sqlcode < 0) sqlprint();}
- #line 50 "array_of_struct.pgc"
- { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table customers ( c varchar ( 50 ) , p int )", ECPGt_EOIT, ECPGt_EORT);
- #line 52 "array_of_struct.pgc"
- if (sqlca.sqlwarn[0] == 'W') sqlprint();
- #line 52 "array_of_struct.pgc"
- if (sqlca.sqlcode < 0) sqlprint();}
- #line 52 "array_of_struct.pgc"
- { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into customers values ( 'John Doe' , '12345' )", ECPGt_EOIT, ECPGt_EORT);
- #line 53 "array_of_struct.pgc"
- if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint();
- #line 53 "array_of_struct.pgc"
- if (sqlca.sqlwarn[0] == 'W') sqlprint();
- #line 53 "array_of_struct.pgc"
- if (sqlca.sqlcode < 0) sqlprint();}
- #line 53 "array_of_struct.pgc"
- { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into customers values ( 'Jane Doe' , '67890' )", ECPGt_EOIT, ECPGt_EORT);
- #line 54 "array_of_struct.pgc"
- if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint();
- #line 54 "array_of_struct.pgc"
- if (sqlca.sqlwarn[0] == 'W') sqlprint();
- #line 54 "array_of_struct.pgc"
- if (sqlca.sqlcode < 0) sqlprint();}
- #line 54 "array_of_struct.pgc"
- { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select * from customers limit 2", ECPGt_EOIT,
- ECPGt_varchar,&(custs1->name),(long)50,(long)10,sizeof( customer ),
- =====================================================================
- Found a 60 line (277 tokens) duplication in the following files:
- Starting at line 33 of /home/shackle/pggit/postgresql/contrib/bloom/blvalidate.c
- Starting at line 34 of /home/shackle/pggit/postgresql/src/backend/access/gin/ginvalidate.c
- Starting at line 34 of /home/shackle/pggit/postgresql/src/backend/access/gist/gistvalidate.c
- blvalidate(Oid opclassoid)
- {
- bool result = true;
- HeapTuple classtup;
- Form_pg_opclass classform;
- Oid opfamilyoid;
- Oid opcintype;
- Oid opckeytype;
- char *opclassname;
- HeapTuple familytup;
- Form_pg_opfamily familyform;
- char *opfamilyname;
- CatCList *proclist,
- *oprlist;
- List *grouplist;
- OpFamilyOpFuncGroup *opclassgroup;
- int i;
- ListCell *lc;
- /* Fetch opclass information */
- classtup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclassoid));
- if (!HeapTupleIsValid(classtup))
- elog(ERROR, "cache lookup failed for operator class %u", opclassoid);
- classform = (Form_pg_opclass) GETSTRUCT(classtup);
- opfamilyoid = classform->opcfamily;
- opcintype = classform->opcintype;
- opckeytype = classform->opckeytype;
- if (!OidIsValid(opckeytype))
- opckeytype = opcintype;
- opclassname = NameStr(classform->opcname);
- /* Fetch opfamily information */
- familytup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfamilyoid));
- if (!HeapTupleIsValid(familytup))
- elog(ERROR, "cache lookup failed for operator family %u", opfamilyoid);
- familyform = (Form_pg_opfamily) GETSTRUCT(familytup);
- opfamilyname = NameStr(familyform->opfname);
- /* Fetch all operators and support functions of the opfamily */
- oprlist = SearchSysCacheList1(AMOPSTRATEGY, ObjectIdGetDatum(opfamilyoid));
- proclist = SearchSysCacheList1(AMPROCNUM, ObjectIdGetDatum(opfamilyoid));
- /* Check individual support functions */
- for (i = 0; i < proclist->n_members; i++)
- {
- HeapTuple proctup = &proclist->members[i]->tuple;
- Form_pg_amproc procform = (Form_pg_amproc) GETSTRUCT(proctup);
- bool ok;
- /*
- * All bloom support functions should be registered with matching
- * left/right types
- */
- if (procform->amproclefttype != procform->amprocrighttype)
- {
- ereport(INFO,
- (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
- errmsg("bloom opfamily %s contains support procedure %s with cross-type registration",
- =====================================================================
- Found a 58 line (273 tokens) duplication in the following files:
- Starting at line 6667 of /home/shackle/pggit/postgresql/src/backend/utils/misc/guc.c
- Starting at line 6757 of /home/shackle/pggit/postgresql/src/backend/utils/misc/guc.c
- Starting at line 6847 of /home/shackle/pggit/postgresql/src/backend/utils/misc/guc.c
- Starting at line 7050 of /home/shackle/pggit/postgresql/src/backend/utils/misc/guc.c
- if (!call_bool_check_hook(conf, &newval, &newextra,
- source, elevel))
- return 0;
- }
- else
- {
- newval = conf->reset_val;
- newextra = conf->reset_extra;
- source = conf->gen.reset_source;
- context = conf->gen.reset_scontext;
- }
- if (prohibitValueChange)
- {
- if (*conf->variable != newval)
- {
- record->status |= GUC_PENDING_RESTART;
- ereport(elevel,
- (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
- errmsg("parameter \"%s\" cannot be changed without restarting the server",
- name)));
- return 0;
- }
- record->status &= ~GUC_PENDING_RESTART;
- return -1;
- }
- if (changeVal)
- {
- /* Save old value to support transaction abort */
- if (!makeDefault)
- push_old_value(&conf->gen, action);
- if (conf->assign_hook)
- conf->assign_hook(newval, newextra);
- *conf->variable = newval;
- set_extra_field(&conf->gen, &conf->gen.extra,
- newextra);
- conf->gen.source = source;
- conf->gen.scontext = context;
- }
- if (makeDefault)
- {
- GucStack *stack;
- if (conf->gen.reset_source <= source)
- {
- conf->reset_val = newval;
- set_extra_field(&conf->gen, &conf->reset_extra,
- newextra);
- conf->gen.reset_source = source;
- conf->gen.reset_scontext = context;
- }
- for (stack = conf->gen.stack; stack; stack = stack->prev)
- {
- if (stack->source <= source)
- {
- stack->prior.val.boolval = newval;
- =====================================================================
- Found a 39 line (272 tokens) duplication in the following files:
- Starting at line 10207 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_dump.c
- Starting at line 10562 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_dump.c
- Starting at line 10941 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_dump.c
- appendPQExpBufferStr(q, "\n);\n");
- if (dopt->binary_upgrade)
- binary_upgrade_extension_member(q, &tyinfo->dobj,
- "TYPE", qtypname,
- tyinfo->dobj.namespace->dobj.name);
- if (tyinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
- ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId,
- tyinfo->dobj.name,
- tyinfo->dobj.namespace->dobj.name,
- NULL,
- tyinfo->rolname,
- "TYPE", SECTION_PRE_DATA,
- q->data, delq->data, NULL,
- NULL, 0,
- NULL, NULL);
- /* Dump Type Comments and Security Labels */
- if (tyinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
- dumpComment(fout, "TYPE", qtypname,
- tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
- tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
- if (tyinfo->dobj.dump & DUMP_COMPONENT_SECLABEL)
- dumpSecLabel(fout, "TYPE", qtypname,
- tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
- tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
- if (tyinfo->dobj.dump & DUMP_COMPONENT_ACL)
- dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
- qtypname, NULL,
- tyinfo->dobj.namespace->dobj.name,
- tyinfo->rolname, tyinfo->typacl, tyinfo->rtypacl,
- tyinfo->inittypacl, tyinfo->initrtypacl);
- PQclear(res);
- destroyPQExpBuffer(q);
- destroyPQExpBuffer(delq);
- =====================================================================
- Found a 52 line (271 tokens) duplication in the following files:
- Starting at line 276 of /home/shackle/pggit/postgresql/src/backend/utils/adt/network_selfuncs.c
- Starting at line 406 of /home/shackle/pggit/postgresql/src/backend/utils/adt/network_selfuncs.c
- int mcv1_length = 0,
- mcv2_length = 0;
- AttStatsSlot mcv1_slot;
- AttStatsSlot mcv2_slot;
- AttStatsSlot hist1_slot;
- AttStatsSlot hist2_slot;
- if (HeapTupleIsValid(vardata1->statsTuple))
- {
- stats = (Form_pg_statistic) GETSTRUCT(vardata1->statsTuple);
- nullfrac1 = stats->stanullfrac;
- mcv1_exists = get_attstatsslot(&mcv1_slot, vardata1->statsTuple,
- STATISTIC_KIND_MCV, InvalidOid,
- ATTSTATSSLOT_VALUES | ATTSTATSSLOT_NUMBERS);
- hist1_exists = get_attstatsslot(&hist1_slot, vardata1->statsTuple,
- STATISTIC_KIND_HISTOGRAM, InvalidOid,
- ATTSTATSSLOT_VALUES);
- /* Arbitrarily limit number of MCVs considered */
- mcv1_length = Min(mcv1_slot.nvalues, MAX_CONSIDERED_ELEMS);
- if (mcv1_exists)
- sumcommon1 = mcv_population(mcv1_slot.numbers, mcv1_length);
- }
- else
- {
- memset(&mcv1_slot, 0, sizeof(mcv1_slot));
- memset(&hist1_slot, 0, sizeof(hist1_slot));
- }
- if (HeapTupleIsValid(vardata2->statsTuple))
- {
- stats = (Form_pg_statistic) GETSTRUCT(vardata2->statsTuple);
- nullfrac2 = stats->stanullfrac;
- mcv2_exists = get_attstatsslot(&mcv2_slot, vardata2->statsTuple,
- STATISTIC_KIND_MCV, InvalidOid,
- ATTSTATSSLOT_VALUES | ATTSTATSSLOT_NUMBERS);
- hist2_exists = get_attstatsslot(&hist2_slot, vardata2->statsTuple,
- STATISTIC_KIND_HISTOGRAM, InvalidOid,
- ATTSTATSSLOT_VALUES);
- /* Arbitrarily limit number of MCVs considered */
- mcv2_length = Min(mcv2_slot.nvalues, MAX_CONSIDERED_ELEMS);
- if (mcv2_exists)
- sumcommon2 = mcv_population(mcv2_slot.numbers, mcv2_length);
- }
- else
- {
- memset(&mcv2_slot, 0, sizeof(mcv2_slot));
- memset(&hist2_slot, 0, sizeof(hist2_slot));
- }
- opr_codenum = inet_opr_codenum(operator);
- =====================================================================
- Found a 37 line (270 tokens) duplication in the following files:
- Starting at line 10082 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_dump.c
- Starting at line 10943 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_dump.c
- if (dopt->binary_upgrade)
- binary_upgrade_extension_member(q, &tyinfo->dobj,
- "TYPE", qtypname,
- tyinfo->dobj.namespace->dobj.name);
- if (tyinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
- ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId,
- tyinfo->dobj.name,
- tyinfo->dobj.namespace->dobj.name,
- NULL,
- tyinfo->rolname,
- "TYPE", SECTION_PRE_DATA,
- q->data, delq->data, NULL,
- NULL, 0,
- NULL, NULL);
- /* Dump Type Comments and Security Labels */
- if (tyinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
- dumpComment(fout, "TYPE", qtypname,
- tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
- tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
- if (tyinfo->dobj.dump & DUMP_COMPONENT_SECLABEL)
- dumpSecLabel(fout, "TYPE", qtypname,
- tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
- tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
- if (tyinfo->dobj.dump & DUMP_COMPONENT_ACL)
- dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
- qtypname, NULL,
- tyinfo->dobj.namespace->dobj.name,
- tyinfo->rolname, tyinfo->typacl, tyinfo->rtypacl,
- tyinfo->inittypacl, tyinfo->initrtypacl);
- PQclear(res);
- destroyPQExpBuffer(q);
- destroyPQExpBuffer(delq);
- =====================================================================
- Found a 43 line (269 tokens) duplication in the following files:
- Starting at line 1190 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/ecpglib/execute.c
- Starting at line 1245 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/ecpglib/execute.c
- for (i = 0; i < sqlda->sqld; i++)
- {
- if (i + 1 == desc_counter)
- {
- desc_inlist.type = sqlda->sqlvar[i].sqltype;
- desc_inlist.value = sqlda->sqlvar[i].sqldata;
- desc_inlist.pointer = &(sqlda->sqlvar[i].sqldata);
- switch (desc_inlist.type)
- {
- case ECPGt_char:
- case ECPGt_varchar:
- desc_inlist.varcharsize = strlen(sqlda->sqlvar[i].sqldata);
- break;
- default:
- desc_inlist.varcharsize = 0;
- break;
- }
- desc_inlist.arrsize = 1;
- desc_inlist.offset = 0;
- if (sqlda->sqlvar[i].sqlind)
- {
- desc_inlist.ind_type = ECPGt_short;
- /* ECPG expects indicator value < 0 */
- if (*(sqlda->sqlvar[i].sqlind))
- *(sqlda->sqlvar[i].sqlind) = -1;
- desc_inlist.ind_value = sqlda->sqlvar[i].sqlind;
- desc_inlist.ind_pointer = &(sqlda->sqlvar[i].sqlind);
- desc_inlist.ind_varcharsize = desc_inlist.ind_arrsize = 1;
- desc_inlist.ind_offset = 0;
- }
- else
- {
- desc_inlist.ind_type = ECPGt_NO_INDICATOR;
- desc_inlist.ind_value = desc_inlist.ind_pointer = NULL;
- desc_inlist.ind_varcharsize = desc_inlist.ind_arrsize = desc_inlist.ind_offset = 0;
- }
- if (!ecpg_store_input(stmt->lineno, stmt->force_indicator, &desc_inlist, &tobeinserted, false))
- return false;
- break;
- }
- }
- if (sqlda->sqld == desc_counter)
- =====================================================================
- Found a 50 line (267 tokens) duplication in the following files:
- Starting at line 17 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/include/pgtypes_numeric.h
- Starting at line 66 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-sqlda.c
- Starting at line 44 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-outofscope.c
- typedef unsigned char NumericDigit;
- typedef struct
- {
- int ndigits; /* number of digits in digits[] - can be 0! */
- int weight; /* weight of first digit */
- int rscale; /* result scale */
- int dscale; /* display scale */
- int sign; /* NUMERIC_POS, NUMERIC_NEG, or NUMERIC_NAN */
- NumericDigit *buf; /* start of alloc'd space for digits[] */
- NumericDigit *digits; /* decimal digits */
- } numeric;
- typedef struct
- {
- int ndigits; /* number of digits in digits[] - can be 0! */
- int weight; /* weight of first digit */
- int rscale; /* result scale */
- int dscale; /* display scale */
- int sign; /* NUMERIC_POS, NUMERIC_NEG, or NUMERIC_NAN */
- NumericDigit digits[DECSIZE]; /* decimal digits */
- } decimal;
- #ifdef __cplusplus
- extern "C"
- {
- #endif
- numeric *PGTYPESnumeric_new(void);
- decimal *PGTYPESdecimal_new(void);
- void PGTYPESnumeric_free(numeric *);
- void PGTYPESdecimal_free(decimal *);
- numeric *PGTYPESnumeric_from_asc(char *, char **);
- char *PGTYPESnumeric_to_asc(numeric *, int);
- int PGTYPESnumeric_add(numeric *, numeric *, numeric *);
- int PGTYPESnumeric_sub(numeric *, numeric *, numeric *);
- int PGTYPESnumeric_mul(numeric *, numeric *, numeric *);
- int PGTYPESnumeric_div(numeric *, numeric *, numeric *);
- int PGTYPESnumeric_cmp(numeric *, numeric *);
- int PGTYPESnumeric_from_int(signed int, numeric *);
- int PGTYPESnumeric_from_long(signed long int, numeric *);
- int PGTYPESnumeric_copy(numeric *, numeric *);
- int PGTYPESnumeric_from_double(double, numeric *);
- int PGTYPESnumeric_to_double(numeric *, double *);
- int PGTYPESnumeric_to_int(numeric *, int *);
- int PGTYPESnumeric_to_long(numeric *, long *);
- int PGTYPESnumeric_to_decimal(numeric *, decimal *);
- int PGTYPESnumeric_from_decimal(decimal *, numeric *);
- #ifdef __cplusplus
- }
- =====================================================================
- Found a 36 line (262 tokens) duplication in the following files:
- Starting at line 10279 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_dump.c
- Starting at line 10941 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_dump.c
- appendPQExpBuffer(q, "CREATE TYPE %s;\n",
- qualtypname);
- if (dopt->binary_upgrade)
- binary_upgrade_extension_member(q, &tyinfo->dobj,
- "TYPE", qtypname,
- tyinfo->dobj.namespace->dobj.name);
- if (tyinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
- ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId,
- tyinfo->dobj.name,
- tyinfo->dobj.namespace->dobj.name,
- NULL,
- tyinfo->rolname,
- "TYPE", SECTION_PRE_DATA,
- q->data, delq->data, NULL,
- NULL, 0,
- NULL, NULL);
- /* Dump Type Comments and Security Labels */
- if (tyinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
- dumpComment(fout, "TYPE", qtypname,
- tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
- tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
- if (tyinfo->dobj.dump & DUMP_COMPONENT_SECLABEL)
- dumpSecLabel(fout, "TYPE", qtypname,
- tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
- tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
- if (tyinfo->dobj.dump & DUMP_COMPONENT_ACL)
- dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
- qtypname, NULL,
- tyinfo->dobj.namespace->dobj.name,
- tyinfo->rolname, tyinfo->typacl, tyinfo->rtypacl,
- tyinfo->inittypacl, tyinfo->initrtypacl);
- =====================================================================
- Found a 35 line (260 tokens) duplication in the following files:
- Starting at line 10207 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_dump.c
- Starting at line 10280 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_dump.c
- Starting at line 10562 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_dump.c
- appendPQExpBufferStr(q, "\n);\n");
- if (dopt->binary_upgrade)
- binary_upgrade_extension_member(q, &tyinfo->dobj,
- "TYPE", qtypname,
- tyinfo->dobj.namespace->dobj.name);
- if (tyinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
- ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId,
- tyinfo->dobj.name,
- tyinfo->dobj.namespace->dobj.name,
- NULL,
- tyinfo->rolname,
- "TYPE", SECTION_PRE_DATA,
- q->data, delq->data, NULL,
- NULL, 0,
- NULL, NULL);
- /* Dump Type Comments and Security Labels */
- if (tyinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
- dumpComment(fout, "TYPE", qtypname,
- tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
- tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
- if (tyinfo->dobj.dump & DUMP_COMPONENT_SECLABEL)
- dumpSecLabel(fout, "TYPE", qtypname,
- tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
- tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
- if (tyinfo->dobj.dump & DUMP_COMPONENT_ACL)
- dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
- qtypname, NULL,
- tyinfo->dobj.namespace->dobj.name,
- tyinfo->rolname, tyinfo->typacl, tyinfo->rtypacl,
- tyinfo->inittypacl, tyinfo->initrtypacl);
- =====================================================================
- Found a 33 line (258 tokens) duplication in the following files:
- Starting at line 10082 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_dump.c
- Starting at line 10282 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_dump.c
- if (dopt->binary_upgrade)
- binary_upgrade_extension_member(q, &tyinfo->dobj,
- "TYPE", qtypname,
- tyinfo->dobj.namespace->dobj.name);
- if (tyinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
- ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId,
- tyinfo->dobj.name,
- tyinfo->dobj.namespace->dobj.name,
- NULL,
- tyinfo->rolname,
- "TYPE", SECTION_PRE_DATA,
- q->data, delq->data, NULL,
- NULL, 0,
- NULL, NULL);
- /* Dump Type Comments and Security Labels */
- if (tyinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
- dumpComment(fout, "TYPE", qtypname,
- tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
- tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
- if (tyinfo->dobj.dump & DUMP_COMPONENT_SECLABEL)
- dumpSecLabel(fout, "TYPE", qtypname,
- tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
- tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
- if (tyinfo->dobj.dump & DUMP_COMPONENT_ACL)
- dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
- qtypname, NULL,
- tyinfo->dobj.namespace->dobj.name,
- tyinfo->rolname, tyinfo->typacl, tyinfo->rtypacl,
- tyinfo->inittypacl, tyinfo->initrtypacl);
- =====================================================================
- Found a 53 line (257 tokens) duplication in the following files:
- Starting at line 310 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
- Starting at line 657 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
- int ncolumns;
- int i;
- Datum *values;
- bool *nulls;
- StringInfoData buf;
- check_stack_depth(); /* recurses for record-type columns */
- /* Extract type info from the tuple itself */
- tupType = HeapTupleHeaderGetTypeId(rec);
- tupTypmod = HeapTupleHeaderGetTypMod(rec);
- tupdesc = lookup_rowtype_tupdesc(tupType, tupTypmod);
- ncolumns = tupdesc->natts;
- /* Build a temporary HeapTuple control structure */
- tuple.t_len = HeapTupleHeaderGetDatumLength(rec);
- ItemPointerSetInvalid(&(tuple.t_self));
- tuple.t_tableOid = InvalidOid;
- tuple.t_data = rec;
- /*
- * We arrange to look up the needed I/O info just once per series of
- * calls, assuming the record type doesn't change underneath us.
- */
- my_extra = (RecordIOData *) fcinfo->flinfo->fn_extra;
- if (my_extra == NULL ||
- my_extra->ncolumns != ncolumns)
- {
- fcinfo->flinfo->fn_extra =
- MemoryContextAlloc(fcinfo->flinfo->fn_mcxt,
- offsetof(RecordIOData, columns) +
- ncolumns * sizeof(ColumnIOData));
- my_extra = (RecordIOData *) fcinfo->flinfo->fn_extra;
- my_extra->record_type = InvalidOid;
- my_extra->record_typmod = 0;
- }
- if (my_extra->record_type != tupType ||
- my_extra->record_typmod != tupTypmod)
- {
- MemSet(my_extra, 0,
- offsetof(RecordIOData, columns) +
- ncolumns * sizeof(ColumnIOData));
- my_extra->record_type = tupType;
- my_extra->record_typmod = tupTypmod;
- my_extra->ncolumns = ncolumns;
- }
- values = (Datum *) palloc(ncolumns * sizeof(Datum));
- nulls = (bool *) palloc(ncolumns * sizeof(bool));
- /* Break down the tuple into fields */
- heap_deform_tuple(&tuple, tupdesc, values, nulls);
- =====================================================================
- Found a 8 line (255 tokens) duplication in the following files:
- Starting at line 120 of /home/shackle/pggit/postgresql/src/backend/access/heap/visibilitymap.c
- Starting at line 128 of /home/shackle/pggit/postgresql/src/backend/access/heap/visibilitymap.c
- 0, 1, 0, 1, 1, 2, 1, 2, 0, 1, 0, 1, 1, 2, 1, 2,
- 1, 2, 1, 2, 2, 3, 2, 3, 1, 2, 1, 2, 2, 3, 2, 3,
- 0, 1, 0, 1, 1, 2, 1, 2, 0, 1, 0, 1, 1, 2, 1, 2,
- 1, 2, 1, 2, 2, 3, 2, 3, 1, 2, 1, 2, 2, 3, 2, 3,
- 1, 2, 1, 2, 2, 3, 2, 3, 1, 2, 1, 2, 2, 3, 2, 3,
- 2, 3, 2, 3, 3, 4, 3, 4, 2, 3, 2, 3, 3, 4, 3, 4,
- 1, 2, 1, 2, 2, 3, 2, 3, 1, 2, 1, 2, 2, 3, 2, 3,
- 2, 3, 2, 3, 3, 4, 3, 4, 2, 3, 2, 3, 3, 4, 3, 4,
- =====================================================================
- Found a 8 line (254 tokens) duplication in the following files:
- Starting at line 72 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
- Starting at line 80 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
- 0, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
- 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
- 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
- 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
- 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
- 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
- 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
- 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
- =====================================================================
- Found a 66 line (245 tokens) duplication in the following files:
- Starting at line 148 of /home/shackle/pggit/postgresql/src/backend/executor/execReplication.c
- Starting at line 315 of /home/shackle/pggit/postgresql/src/backend/executor/execReplication.c
- found = true;
- ExecStoreHeapTuple(scantuple, outslot, false);
- ExecMaterializeSlot(outslot);
- xwait = TransactionIdIsValid(snap.xmin) ?
- snap.xmin : snap.xmax;
- /*
- * If the tuple is locked, wait for locking transaction to finish and
- * retry.
- */
- if (TransactionIdIsValid(xwait))
- {
- XactLockTableWait(xwait, NULL, NULL, XLTW_None);
- goto retry;
- }
- }
- /* Found tuple, try to lock it in the lockmode. */
- if (found)
- {
- Buffer buf;
- HeapUpdateFailureData hufd;
- HTSU_Result res;
- HeapTupleData locktup;
- HeapTupleTableSlot *hslot = (HeapTupleTableSlot *)outslot;
- /* Only a heap tuple has item pointers. */
- Assert(TTS_IS_HEAPTUPLE(outslot) || TTS_IS_BUFFERTUPLE(outslot));
- ItemPointerCopy(&hslot->tuple->t_self, &locktup.t_self);
- PushActiveSnapshot(GetLatestSnapshot());
- res = heap_lock_tuple(rel, &locktup, GetCurrentCommandId(false),
- lockmode,
- LockWaitBlock,
- false /* don't follow updates */ ,
- &buf, &hufd);
- /* the tuple slot already has the buffer pinned */
- ReleaseBuffer(buf);
- PopActiveSnapshot();
- switch (res)
- {
- case HeapTupleMayBeUpdated:
- break;
- case HeapTupleUpdated:
- /* XXX: Improve handling here */
- if (ItemPointerIndicatesMovedPartitions(&hufd.ctid))
- ereport(LOG,
- (errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
- errmsg("tuple to be locked was already moved to another partition due to concurrent update, retrying")));
- else
- ereport(LOG,
- (errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
- errmsg("concurrent update, retrying")));
- goto retry;
- case HeapTupleInvisible:
- elog(ERROR, "attempted to lock invisible tuple");
- break;
- default:
- elog(ERROR, "unexpected heap_lock_tuple status: %u", res);
- break;
- }
- }
- =====================================================================
- Found a 44 line (243 tokens) duplication in the following files:
- Starting at line 259 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-describe.c
- Starting at line 388 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-describe.c
- for (i = 1; i <= count1; i++)
- {
- { ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
- ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
- #line 115 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 115 "describe.pgc"
- { ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
- ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
- #line 116 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 116 "describe.pgc"
- printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
- "sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n",
- i, field_name1, field_name2,
- sqlda1->sqlvar[i-1].sqlname.data,
- sqlda2->sqlvar[i-1].sqlname.data,
- sqlda3->sqlvar[i-1].sqlname.data);
- }
- strcpy(msg, "deallocate");
- ECPGdeallocate_desc(__LINE__, "desc1");
- #line 126 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);
- #line 126 "describe.pgc"
- ECPGdeallocate_desc(__LINE__, "desc2");
- #line 127 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);
- #line 127 "describe.pgc"
- free(sqlda1);
- free(sqlda2);
- free(sqlda3);
- { ECPGdeallocate(__LINE__, 0, NULL, "st_id1");
- =====================================================================
- Found a 61 line (241 tokens) duplication in the following files:
- Starting at line 186 of /home/shackle/pggit/postgresql/src/backend/utils/adt/varbit.c
- Starting at line 498 of /home/shackle/pggit/postgresql/src/backend/utils/adt/varbit.c
- VARBITLEN(result) = atttypmod;
- r = VARBITS(result);
- if (bit_not_hex)
- {
- /* Parse the bit representation of the string */
- /* We know it fits, as bitlen was compared to atttypmod */
- x = HIGHBIT;
- for (; *sp; sp++)
- {
- if (*sp == '1')
- *r |= x;
- else if (*sp != '0')
- ereport(ERROR,
- (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
- errmsg("\"%c\" is not a valid binary digit",
- *sp)));
- x >>= 1;
- if (x == 0)
- {
- x = HIGHBIT;
- r++;
- }
- }
- }
- else
- {
- /* Parse the hex representation of the string */
- for (bc = 0; *sp; sp++)
- {
- if (*sp >= '0' && *sp <= '9')
- x = (bits8) (*sp - '0');
- else if (*sp >= 'A' && *sp <= 'F')
- x = (bits8) (*sp - 'A') + 10;
- else if (*sp >= 'a' && *sp <= 'f')
- x = (bits8) (*sp - 'a') + 10;
- else
- ereport(ERROR,
- (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
- errmsg("\"%c\" is not a valid hexadecimal digit",
- *sp)));
- if (bc)
- {
- *r++ |= x;
- bc = 0;
- }
- else
- {
- *r = x << 4;
- bc = 1;
- }
- }
- }
- PG_RETURN_VARBIT_P(result);
- }
- Datum
- =====================================================================
- Found a 44 line (237 tokens) duplication in the following files:
- Starting at line 261 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/compat_informix-describe.c
- Starting at line 390 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/compat_informix-describe.c
- for (i = 1; i <= count1; i++)
- {
- { ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
- ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
- #line 115 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 115 "describe.pgc"
- { ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
- ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
- #line 116 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 116 "describe.pgc"
- printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
- "sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n",
- i, field_name1, field_name2,
- sqlda1->sqlvar[i-1].sqlname,
- sqlda2->sqlvar[i-1].sqlname,
- sqlda3->sqlvar[i-1].sqlname);
- }
- strcpy(msg, "deallocate");
- ECPGdeallocate_desc(__LINE__, "desc1");
- #line 126 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);
- #line 126 "describe.pgc"
- ECPGdeallocate_desc(__LINE__, "desc2");
- #line 127 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);
- #line 127 "describe.pgc"
- free(sqlda1);
- free(sqlda2);
- free(sqlda3);
- { ECPGdeallocate(__LINE__, 1, NULL, "st_id1");
- =====================================================================
- Found a 59 line (237 tokens) duplication in the following files:
- Starting at line 7295 of /home/shackle/pggit/postgresql/src/backend/utils/adt/selfuncs.c
- Starting at line 7356 of /home/shackle/pggit/postgresql/src/backend/utils/adt/selfuncs.c
- gistcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
- Cost *indexStartupCost, Cost *indexTotalCost,
- Selectivity *indexSelectivity, double *indexCorrelation,
- double *indexPages)
- {
- IndexOptInfo *index = path->indexinfo;
- List *qinfos;
- GenericCosts costs;
- Cost descentCost;
- /* Do preliminary analysis of indexquals */
- qinfos = deconstruct_indexquals(path);
- MemSet(&costs, 0, sizeof(costs));
- genericcostestimate(root, path, loop_count, qinfos, &costs);
- /*
- * We model index descent costs similarly to those for btree, but to do
- * that we first need an idea of the tree height. We somewhat arbitrarily
- * assume that the fanout is 100, meaning the tree height is at most
- * log100(index->pages).
- *
- * Although this computation isn't really expensive enough to require
- * caching, we might as well use index->tree_height to cache it.
- */
- if (index->tree_height < 0) /* unknown? */
- {
- if (index->pages > 1) /* avoid computing log(0) */
- index->tree_height = (int) (log(index->pages) / log(100.0));
- else
- index->tree_height = 0;
- }
- /*
- * Add a CPU-cost component to represent the costs of initial descent. We
- * just use log(N) here not log2(N) since the branching factor isn't
- * necessarily two anyway. As for btree, charge once per SA scan.
- */
- if (index->tuples > 1) /* avoid computing log(0) */
- {
- descentCost = ceil(log(index->tuples)) * cpu_operator_cost;
- costs.indexStartupCost += descentCost;
- costs.indexTotalCost += costs.num_sa_scans * descentCost;
- }
- /*
- * Likewise add a per-page charge, calculated the same as for btrees.
- */
- descentCost = (index->tree_height + 1) * 50.0 * cpu_operator_cost;
- costs.indexStartupCost += descentCost;
- costs.indexTotalCost += costs.num_sa_scans * descentCost;
- *indexStartupCost = costs.indexStartupCost;
- *indexTotalCost = costs.indexTotalCost;
- *indexSelectivity = costs.indexSelectivity;
- *indexCorrelation = costs.indexCorrelation;
- *indexPages = costs.numIndexPages;
- }
- =====================================================================
- Found a 15 line (234 tokens) duplication in the following files:
- Starting at line 121 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/compat_informix-rnull.c
- Starting at line 159 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/compat_informix-rnull.c
- Starting at line 194 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/compat_informix-rnull.c
- Starting at line 234 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/compat_informix-rnull.c
- { 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 )",
- ECPGt_char,(c),(long)sizeof("abc"),(long)1,(sizeof("abc"))*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_short,&(s),(long)1,(long)1,sizeof(short),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_int,&(i),(long)1,(long)1,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_bool,&(b),(long)1,(long)1,sizeof(bool),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_float,&(f),(long)1,(long)1,sizeof(float),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_long,&(l),(long)1,(long)1,sizeof(long),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_double,&(dbl),(long)1,(long)1,sizeof(double),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
- =====================================================================
- Found a 38 line (231 tokens) duplication in the following files:
- Starting at line 3847 of /home/shackle/pggit/postgresql/src/backend/utils/adt/timestamp.c
- Starting at line 3982 of /home/shackle/pggit/postgresql/src/backend/utils/adt/timestamp.c
- fsec = 0;
- break;
- }
- case DTK_MILLENNIUM:
- /* see comments in timestamptz_trunc */
- if (tm->tm_year > 0)
- tm->tm_year = ((tm->tm_year + 999) / 1000) * 1000 - 999;
- else
- tm->tm_year = -((999 - (tm->tm_year - 1)) / 1000) * 1000 + 1;
- /* FALL THRU */
- case DTK_CENTURY:
- /* see comments in timestamptz_trunc */
- if (tm->tm_year > 0)
- tm->tm_year = ((tm->tm_year + 99) / 100) * 100 - 99;
- else
- tm->tm_year = -((99 - (tm->tm_year - 1)) / 100) * 100 + 1;
- /* FALL THRU */
- case DTK_DECADE:
- /* see comments in timestamptz_trunc */
- if (val != DTK_MILLENNIUM && val != DTK_CENTURY)
- {
- if (tm->tm_year > 0)
- tm->tm_year = (tm->tm_year / 10) * 10;
- else
- tm->tm_year = -((8 - (tm->tm_year - 1)) / 10) * 10;
- }
- /* FALL THRU */
- case DTK_YEAR:
- tm->tm_mon = 1;
- /* FALL THRU */
- case DTK_QUARTER:
- tm->tm_mon = (3 * ((tm->tm_mon - 1) / 3)) + 1;
- /* FALL THRU */
- case DTK_MONTH:
- tm->tm_mday = 1;
- /* FALL THRU */
- case DTK_DAY:
- tm->tm_hour = 0;
- =====================================================================
- Found a 64 line (228 tokens) duplication in the following files:
- Starting at line 2584 of /home/shackle/pggit/postgresql/src/backend/utils/adt/float.c
- Starting at line 2660 of /home/shackle/pggit/postgresql/src/backend/utils/adt/float.c
- transvalues = check_float8_array(transarray, "float8_accum", 3);
- N = transvalues[0];
- Sx = transvalues[1];
- Sxx = transvalues[2];
- /*
- * Use the Youngs-Cramer algorithm to incorporate the new value into the
- * transition values.
- */
- N += 1.0;
- Sx += newval;
- if (transvalues[0] > 0.0)
- {
- tmp = newval * N - Sx;
- Sxx += tmp * tmp / (N * transvalues[0]);
- /*
- * Overflow check. We only report an overflow error when finite
- * inputs lead to infinite results. Note also that Sxx should be NaN
- * if any of the inputs are infinite, so we intentionally prevent Sxx
- * from becoming infinite.
- */
- if (isinf(Sx) || isinf(Sxx))
- {
- if (!isinf(transvalues[1]) && !isinf(newval))
- ereport(ERROR,
- (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
- errmsg("value out of range: overflow")));
- Sxx = get_float8_nan();
- }
- }
- /*
- * If we're invoked as an aggregate, we can cheat and modify our first
- * parameter in-place to reduce palloc overhead. Otherwise we construct a
- * new array with the updated transition data and return it.
- */
- if (AggCheckCallContext(fcinfo, NULL))
- {
- transvalues[0] = N;
- transvalues[1] = Sx;
- transvalues[2] = Sxx;
- PG_RETURN_ARRAYTYPE_P(transarray);
- }
- else
- {
- Datum transdatums[3];
- ArrayType *result;
- transdatums[0] = Float8GetDatumFast(N);
- transdatums[1] = Float8GetDatumFast(Sx);
- transdatums[2] = Float8GetDatumFast(Sxx);
- result = construct_array(transdatums, 3,
- FLOAT8OID,
- sizeof(float8), FLOAT8PASSBYVAL, 'd');
- PG_RETURN_ARRAYTYPE_P(result);
- }
- }
- Datum
- =====================================================================
- Found a 42 line (228 tokens) duplication in the following files:
- Starting at line 1538 of /home/shackle/pggit/postgresql/src/backend/utils/adt/jsonb.c
- Starting at line 1762 of /home/shackle/pggit/postgresql/src/backend/utils/adt/jsonb.c
- it = JsonbIteratorInit(&jbelem->root);
- while ((type = JsonbIteratorNext(&it, &v, false)) != WJB_DONE)
- {
- switch (type)
- {
- case WJB_BEGIN_ARRAY:
- if (v.val.array.rawScalar)
- single_scalar = true;
- else
- result->res = pushJsonbValue(&result->parseState,
- type, NULL);
- break;
- case WJB_END_ARRAY:
- if (!single_scalar)
- result->res = pushJsonbValue(&result->parseState,
- type, NULL);
- break;
- case WJB_BEGIN_OBJECT:
- case WJB_END_OBJECT:
- result->res = pushJsonbValue(&result->parseState,
- type, NULL);
- break;
- case WJB_ELEM:
- case WJB_KEY:
- case WJB_VALUE:
- if (v.type == jbvString)
- {
- /* copy string values in the aggregate context */
- char *buf = palloc(v.val.string.len + 1);
- snprintf(buf, v.val.string.len + 1, "%s", v.val.string.val);
- v.val.string.val = buf;
- }
- else if (v.type == jbvNumeric)
- {
- /* same for numeric */
- v.val.numeric =
- DatumGetNumeric(DirectFunctionCall1(numeric_uplus,
- NumericGetDatum(v.val.numeric)));
- }
- result->res = pushJsonbValue(&result->parseState,
- =====================================================================
- Found a 77 line (228 tokens) duplication in the following files:
- Starting at line 291 of /home/shackle/pggit/postgresql/src/backend/access/common/indextuple.c
- Starting at line 494 of /home/shackle/pggit/postgresql/src/backend/access/common/heaptuple.c
- if (IndexTupleHasVarwidths(tup))
- {
- int j;
- for (j = 0; j <= attnum; j++)
- {
- if (TupleDescAttr(tupleDesc, j)->attlen <= 0)
- {
- slow = true;
- break;
- }
- }
- }
- }
- if (!slow)
- {
- int natts = tupleDesc->natts;
- int j = 1;
- /*
- * If we get here, we have a tuple with no nulls or var-widths up to
- * and including the target attribute, so we can use the cached offset
- * ... only we don't have it yet, or we'd not have got here. Since
- * it's cheap to compute offsets for fixed-width columns, we take the
- * opportunity to initialize the cached offsets for *all* the leading
- * fixed-width columns, in hope of avoiding future visits to this
- * routine.
- */
- TupleDescAttr(tupleDesc, 0)->attcacheoff = 0;
- /* we might have set some offsets in the slow path previously */
- while (j < natts && TupleDescAttr(tupleDesc, j)->attcacheoff > 0)
- j++;
- off = TupleDescAttr(tupleDesc, j - 1)->attcacheoff +
- TupleDescAttr(tupleDesc, j - 1)->attlen;
- for (; j < natts; j++)
- {
- Form_pg_attribute att = TupleDescAttr(tupleDesc, j);
- if (att->attlen <= 0)
- break;
- off = att_align_nominal(off, att->attalign);
- att->attcacheoff = off;
- off += att->attlen;
- }
- Assert(j > attnum);
- off = TupleDescAttr(tupleDesc, attnum)->attcacheoff;
- }
- else
- {
- bool usecache = true;
- int i;
- /*
- * Now we know that we have to walk the tuple CAREFULLY. But we still
- * might be able to cache some offsets for next time.
- *
- * Note - This loop is a little tricky. For each non-null attribute,
- * we have to first account for alignment padding before the attr,
- * then advance over the attr based on its length. Nulls have no
- * storage and no alignment padding either. We can use/set
- * attcacheoff until we reach either a null or a var-width attribute.
- */
- off = 0;
- for (i = 0;; i++) /* loop exit is at "break" */
- {
- Form_pg_attribute att = TupleDescAttr(tupleDesc, i);
- if (IndexTupleHasNulls(tup) && att_isnull(i, bp))
- =====================================================================
- Found a 60 line (226 tokens) duplication in the following files:
- Starting at line 711 of /home/shackle/pggit/postgresql/src/bin/pgbench/pgbench.c
- Starting at line 54 of /home/shackle/pggit/postgresql/src/backend/utils/adt/int8.c
- strtoint64(const char *str, bool errorOK, int64 *result)
- {
- const char *ptr = str;
- int64 tmp = 0;
- bool neg = false;
- /*
- * Do our own scan, rather than relying on sscanf which might be broken
- * for long long.
- *
- * As INT64_MIN can't be stored as a positive 64 bit integer, accumulate
- * value as a negative number.
- */
- /* skip leading spaces */
- while (*ptr && isspace((unsigned char) *ptr))
- ptr++;
- /* handle sign */
- if (*ptr == '-')
- {
- ptr++;
- neg = true;
- }
- else if (*ptr == '+')
- ptr++;
- /* require at least one digit */
- if (unlikely(!isdigit((unsigned char) *ptr)))
- goto invalid_syntax;
- /* process digits */
- while (*ptr && isdigit((unsigned char) *ptr))
- {
- int8 digit = (*ptr++ - '0');
- if (unlikely(pg_mul_s64_overflow(tmp, 10, &tmp)) ||
- unlikely(pg_sub_s64_overflow(tmp, digit, &tmp)))
- goto out_of_range;
- }
- /* allow trailing whitespace, but not other trailing chars */
- while (*ptr != '\0' && isspace((unsigned char) *ptr))
- ptr++;
- if (unlikely(*ptr != '\0'))
- goto invalid_syntax;
- if (!neg)
- {
- if (unlikely(tmp == PG_INT64_MIN))
- goto out_of_range;
- tmp = -tmp;
- }
- *result = tmp;
- return true;
- out_of_range:
- if (!errorOK)
- =====================================================================
- Found a 54 line (223 tokens) duplication in the following files:
- Starting at line 1882 of /home/shackle/pggit/postgresql/src/backend/commands/extension.c
- Starting at line 1991 of /home/shackle/pggit/postgresql/src/backend/commands/extension.c
- pg_available_extensions(PG_FUNCTION_ARGS)
- {
- ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo;
- TupleDesc tupdesc;
- Tuplestorestate *tupstore;
- MemoryContext per_query_ctx;
- MemoryContext oldcontext;
- char *location;
- DIR *dir;
- struct dirent *de;
- /* check to see if caller supports us returning a tuplestore */
- if (rsinfo == NULL || !IsA(rsinfo, ReturnSetInfo))
- ereport(ERROR,
- (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("set-valued function called in context that cannot accept a set")));
- if (!(rsinfo->allowedModes & SFRM_Materialize))
- ereport(ERROR,
- (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("materialize mode required, but it is not " \
- "allowed in this context")));
- /* Build a tuple descriptor for our result type */
- if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
- elog(ERROR, "return type must be a row type");
- /* Build tuplestore to hold the result rows */
- per_query_ctx = rsinfo->econtext->ecxt_per_query_memory;
- oldcontext = MemoryContextSwitchTo(per_query_ctx);
- tupstore = tuplestore_begin_heap(true, false, work_mem);
- rsinfo->returnMode = SFRM_Materialize;
- rsinfo->setResult = tupstore;
- rsinfo->setDesc = tupdesc;
- MemoryContextSwitchTo(oldcontext);
- location = get_extension_control_directory();
- dir = AllocateDir(location);
- /*
- * If the control directory doesn't exist, we want to silently return an
- * empty set. Any other error will be reported by ReadDir.
- */
- if (dir == NULL && errno == ENOENT)
- {
- /* do nothing */
- }
- else
- {
- while ((de = ReadDir(dir, location)) != NULL)
- {
- ExtensionControlFile *control;
- char *extname;
- =====================================================================
- Found a 42 line (215 tokens) duplication in the following files:
- Starting at line 4600 of /home/shackle/pggit/postgresql/src/backend/utils/adt/timestamp.c
- Starting at line 4811 of /home/shackle/pggit/postgresql/src/backend/utils/adt/timestamp.c
- if (tm->tm_year >= 0)
- result = tm->tm_year / 10;
- else
- result = -((8 - (tm->tm_year - 1)) / 10);
- break;
- case DTK_CENTURY:
- /* ----
- * centuries AD, c>0: year in [ (c-1)* 100 + 1 : c*100 ]
- * centuries BC, c<0: year in [ c*100 : (c+1) * 100 - 1]
- * there is no number 0 century.
- * ----
- */
- if (tm->tm_year > 0)
- result = (tm->tm_year + 99) / 100;
- else
- /* caution: C division may have negative remainder */
- result = -((99 - (tm->tm_year - 1)) / 100);
- break;
- case DTK_MILLENNIUM:
- /* see comments above. */
- if (tm->tm_year > 0)
- result = (tm->tm_year + 999) / 1000;
- else
- result = -((999 - (tm->tm_year - 1)) / 1000);
- break;
- case DTK_JULIAN:
- result = date2j(tm->tm_year, tm->tm_mon, tm->tm_mday);
- result += ((((tm->tm_hour * MINS_PER_HOUR) + tm->tm_min) * SECS_PER_MINUTE) +
- tm->tm_sec + (fsec / 1000000.0)) / (double) SECS_PER_DAY;
- break;
- case DTK_ISOYEAR:
- result = date2isoyear(tm->tm_year, tm->tm_mon, tm->tm_mday);
- break;
- case DTK_DOW:
- case DTK_ISODOW:
- if (timestamp2tm(timestamp, NULL, tm, &fsec, NULL, NULL) != 0)
- =====================================================================
- Found a 55 line (213 tokens) duplication in the following files:
- Starting at line 88 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
- Starting at line 466 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
- StringInfoData buf;
- check_stack_depth(); /* recurses for record-type columns */
- /*
- * Give a friendly error message if we did not get enough info to identify
- * the target record type. (lookup_rowtype_tupdesc would fail anyway, but
- * with a non-user-friendly message.) In ordinary SQL usage, we'll get -1
- * for typmod, since composite types and RECORD have no type modifiers at
- * the SQL level, and thus must fail for RECORD. However some callers can
- * supply a valid typmod, and then we can do something useful for RECORD.
- */
- if (tupType == RECORDOID && tupTypmod < 0)
- ereport(ERROR,
- (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("input of anonymous composite types is not implemented")));
- /*
- * This comes from the composite type's pg_type.oid and stores system oids
- * in user tables, specifically DatumTupleFields. This oid must be
- * preserved by binary upgrades.
- */
- tupdesc = lookup_rowtype_tupdesc(tupType, tupTypmod);
- ncolumns = tupdesc->natts;
- /*
- * We arrange to look up the needed I/O info just once per series of
- * calls, assuming the record type doesn't change underneath us.
- */
- my_extra = (RecordIOData *) fcinfo->flinfo->fn_extra;
- if (my_extra == NULL ||
- my_extra->ncolumns != ncolumns)
- {
- fcinfo->flinfo->fn_extra =
- MemoryContextAlloc(fcinfo->flinfo->fn_mcxt,
- offsetof(RecordIOData, columns) +
- ncolumns * sizeof(ColumnIOData));
- my_extra = (RecordIOData *) fcinfo->flinfo->fn_extra;
- my_extra->record_type = InvalidOid;
- my_extra->record_typmod = 0;
- }
- if (my_extra->record_type != tupType ||
- my_extra->record_typmod != tupTypmod)
- {
- MemSet(my_extra, 0,
- offsetof(RecordIOData, columns) +
- ncolumns * sizeof(ColumnIOData));
- my_extra->record_type = tupType;
- my_extra->record_typmod = tupTypmod;
- my_extra->ncolumns = ncolumns;
- }
- values = (Datum *) palloc(ncolumns * sizeof(Datum));
- nulls = (bool *) palloc(ncolumns * sizeof(bool));
- =====================================================================
- Found a 23 line (212 tokens) duplication in the following files:
- Starting at line 152 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-oldexec.c
- Starting at line 151 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-execute.c
- { ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "fetch 8 in CUR", ECPGt_EOIT,
- ECPGt_char,(name),(long)8,(long)8,(8)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_int,(amount),(long)1,(long)8,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_char,(letter),(long)1,(long)8,(1)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
- #line 54 "oldexec.pgc"
- if (sqlca.sqlcode < 0) sqlprint();}
- #line 54 "oldexec.pgc"
- for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
- {
- char n[8], l = letter[i][0];
- int a = amount[i];
- strncpy(n, name[i], 8);
- printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l);
- }
- { ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "close CUR", ECPGt_EOIT, ECPGt_EORT);
- =====================================================================
- Found a 23 line (212 tokens) duplication in the following files:
- Starting at line 152 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-oldexec.c
- Starting at line 203 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-oldexec.c
- { ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "fetch 8 in CUR", ECPGt_EOIT,
- ECPGt_char,(name),(long)8,(long)8,(8)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_int,(amount),(long)1,(long)8,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_char,(letter),(long)1,(long)8,(1)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
- #line 54 "oldexec.pgc"
- if (sqlca.sqlcode < 0) sqlprint();}
- #line 54 "oldexec.pgc"
- for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
- {
- char n[8], l = letter[i][0];
- int a = amount[i];
- strncpy(n, name[i], 8);
- printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l);
- }
- { ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "close CUR", ECPGt_EOIT, ECPGt_EORT);
- =====================================================================
- Found a 33 line (212 tokens) duplication in the following files:
- Starting at line 151 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-execute.c
- Starting at line 218 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-execute.c
- { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 8 in CUR", ECPGt_EOIT,
- ECPGt_char,(name),(long)8,(long)8,(8)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_int,(amount),(long)1,(long)8,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_char,(letter),(long)1,(long)8,(1)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
- #line 53 "execute.pgc"
- if (sqlca.sqlcode < 0) sqlprint();}
- #line 53 "execute.pgc"
- for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
- {
- /* exec sql begin declare section */
- #line 58 "execute.pgc"
- char n [ 8 ] , l = letter [ i ] [ 0 ] ;
- #line 59 "execute.pgc"
- int a = amount [ i ] ;
- /* exec sql end declare section */
- #line 60 "execute.pgc"
- strncpy(n, name[i], 8);
- printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l);
- }
- { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close CUR", ECPGt_EOIT, ECPGt_EORT);
- =====================================================================
- Found a 51 line (212 tokens) duplication in the following files:
- Starting at line 36 of /home/shackle/pggit/postgresql/src/backend/access/rmgrdesc/xactdesc.c
- Starting at line 131 of /home/shackle/pggit/postgresql/src/backend/access/rmgrdesc/xactdesc.c
- char *data = ((char *) xlrec) + MinSizeOfXactCommit;
- memset(parsed, 0, sizeof(*parsed));
- parsed->xinfo = 0; /* default, if no XLOG_XACT_HAS_INFO is
- * present */
- parsed->xact_time = xlrec->xact_time;
- if (info & XLOG_XACT_HAS_INFO)
- {
- xl_xact_xinfo *xl_xinfo = (xl_xact_xinfo *) data;
- parsed->xinfo = xl_xinfo->xinfo;
- data += sizeof(xl_xact_xinfo);
- }
- if (parsed->xinfo & XACT_XINFO_HAS_DBINFO)
- {
- xl_xact_dbinfo *xl_dbinfo = (xl_xact_dbinfo *) data;
- parsed->dbId = xl_dbinfo->dbId;
- parsed->tsId = xl_dbinfo->tsId;
- data += sizeof(xl_xact_dbinfo);
- }
- if (parsed->xinfo & XACT_XINFO_HAS_SUBXACTS)
- {
- xl_xact_subxacts *xl_subxacts = (xl_xact_subxacts *) data;
- parsed->nsubxacts = xl_subxacts->nsubxacts;
- parsed->subxacts = xl_subxacts->subxacts;
- data += MinSizeOfXactSubxacts;
- data += parsed->nsubxacts * sizeof(TransactionId);
- }
- if (parsed->xinfo & XACT_XINFO_HAS_RELFILENODES)
- {
- xl_xact_relfilenodes *xl_relfilenodes = (xl_xact_relfilenodes *) data;
- parsed->nrels = xl_relfilenodes->nrels;
- parsed->xnodes = xl_relfilenodes->xnodes;
- data += MinSizeOfXactRelfilenodes;
- data += xl_relfilenodes->nrels * sizeof(RelFileNode);
- }
- if (parsed->xinfo & XACT_XINFO_HAS_INVALS)
- =====================================================================
- Found a 56 line (212 tokens) duplication in the following files:
- Starting at line 513 of /home/shackle/pggit/postgresql/src/backend/access/hash/hash_xlog.c
- Starting at line 641 of /home/shackle/pggit/postgresql/src/backend/access/hash/hash_xlog.c
- Buffer deletebuf = InvalidBuffer;
- XLogRedoAction action;
- /*
- * Ensure we have a cleanup lock on primary bucket page before we start
- * with the actual replay operation. This is to ensure that neither a
- * scan can start nor a scan can be already-in-progress during the replay
- * of this operation. If we allow scans during this operation, then they
- * can miss some records or show the same record multiple times.
- */
- if (xldata->is_prim_bucket_same_wrt)
- action = XLogReadBufferForRedoExtended(record, 1, RBM_NORMAL, true, &writebuf);
- else
- {
- /*
- * we don't care for return value as the purpose of reading bucketbuf
- * is to ensure a cleanup lock on primary bucket page.
- */
- (void) XLogReadBufferForRedoExtended(record, 0, RBM_NORMAL, true, &bucketbuf);
- action = XLogReadBufferForRedo(record, 1, &writebuf);
- }
- /* replay the record for adding entries in overflow buffer */
- if (action == BLK_NEEDS_REDO)
- {
- Page writepage;
- char *begin;
- char *data;
- Size datalen;
- uint16 ninserted = 0;
- data = begin = XLogRecGetBlockData(record, 1, &datalen);
- writepage = (Page) BufferGetPage(writebuf);
- if (xldata->ntups > 0)
- {
- OffsetNumber *towrite = (OffsetNumber *) data;
- data += sizeof(OffsetNumber) * xldata->ntups;
- while (data - begin < datalen)
- {
- IndexTuple itup = (IndexTuple) data;
- Size itemsz;
- OffsetNumber l;
- itemsz = IndexTupleSize(itup);
- itemsz = MAXALIGN(itemsz);
- data += itemsz;
- l = PageAddItem(writepage, (Item) itup, itemsz, towrite[ninserted], false, false);
- if (l == InvalidOffsetNumber)
- elog(ERROR, "hash_xlog_move_page_contents: failed to add item to hash index page, size %d bytes",
- =====================================================================
- Found a 28 line (211 tokens) duplication in the following files:
- Starting at line 641 of /home/shackle/pggit/postgresql/src/backend/regex/regc_lex.c
- Starting at line 997 of /home/shackle/pggit/postgresql/src/backend/regex/regc_lex.c
- RETV(')', c);
- break;
- case CHR('['): /* easy except for [[:<:]] and [[:>:]] */
- if (HAVE(6) && *(v->now + 0) == CHR('[') &&
- *(v->now + 1) == CHR(':') &&
- (*(v->now + 2) == CHR('<') ||
- *(v->now + 2) == CHR('>')) &&
- *(v->now + 3) == CHR(':') &&
- *(v->now + 4) == CHR(']') &&
- *(v->now + 5) == CHR(']'))
- {
- c = *(v->now + 2);
- v->now += 6;
- NOTE(REG_UNONPOSIX);
- RET((c == CHR('<')) ? '<' : '>');
- }
- INTOCON(L_BRACK);
- if (NEXT1('^'))
- {
- v->now++;
- RETV('[', 0);
- }
- RETV('[', 1);
- break;
- case CHR('.'):
- RET('.');
- break;
- case CHR('^'):
- =====================================================================
- Found a 23 line (208 tokens) duplication in the following files:
- Starting at line 152 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-oldexec.c
- Starting at line 218 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-execute.c
- { ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "fetch 8 in CUR", ECPGt_EOIT,
- ECPGt_char,(name),(long)8,(long)8,(8)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_int,(amount),(long)1,(long)8,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_char,(letter),(long)1,(long)8,(1)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
- #line 54 "oldexec.pgc"
- if (sqlca.sqlcode < 0) sqlprint();}
- #line 54 "oldexec.pgc"
- for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
- {
- char n[8], l = letter[i][0];
- int a = amount[i];
- strncpy(n, name[i], 8);
- printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l);
- }
- { ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "close CUR", ECPGt_EOIT, ECPGt_EORT);
- =====================================================================
- Found a 23 line (208 tokens) duplication in the following files:
- Starting at line 203 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-oldexec.c
- Starting at line 151 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-execute.c
- { ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "fetch in CUR3", ECPGt_EOIT,
- ECPGt_char,(name),(long)8,(long)8,(8)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_int,(amount),(long)1,(long)8,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_char,(letter),(long)1,(long)8,(1)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
- #line 73 "oldexec.pgc"
- if (sqlca.sqlcode < 0) sqlprint();}
- #line 73 "oldexec.pgc"
- for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
- {
- char n[8], l = letter[i][0];
- int a = amount[i];
- strncpy(n, name[i], 8);
- printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l);
- }
- { ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "close CUR3", ECPGt_EOIT, ECPGt_EORT);
- =====================================================================
- Found a 52 line (206 tokens) duplication in the following files:
- Starting at line 176 of /home/shackle/pggit/postgresql/src/backend/utils/time/tqual.c
- Starting at line 366 of /home/shackle/pggit/postgresql/src/backend/utils/time/tqual.c
- HeapTupleSatisfiesSelf(HeapTuple htup, Snapshot snapshot, Buffer buffer)
- {
- HeapTupleHeader tuple = htup->t_data;
- Assert(ItemPointerIsValid(&htup->t_self));
- Assert(htup->t_tableOid != InvalidOid);
- if (!HeapTupleHeaderXminCommitted(tuple))
- {
- if (HeapTupleHeaderXminInvalid(tuple))
- return false;
- /* Used by pre-9.0 binary upgrades */
- if (tuple->t_infomask & HEAP_MOVED_OFF)
- {
- TransactionId xvac = HeapTupleHeaderGetXvac(tuple);
- if (TransactionIdIsCurrentTransactionId(xvac))
- return false;
- if (!TransactionIdIsInProgress(xvac))
- {
- if (TransactionIdDidCommit(xvac))
- {
- SetHintBits(tuple, buffer, HEAP_XMIN_INVALID,
- InvalidTransactionId);
- return false;
- }
- SetHintBits(tuple, buffer, HEAP_XMIN_COMMITTED,
- InvalidTransactionId);
- }
- }
- /* Used by pre-9.0 binary upgrades */
- else if (tuple->t_infomask & HEAP_MOVED_IN)
- {
- TransactionId xvac = HeapTupleHeaderGetXvac(tuple);
- if (!TransactionIdIsCurrentTransactionId(xvac))
- {
- if (TransactionIdIsInProgress(xvac))
- return false;
- if (TransactionIdDidCommit(xvac))
- SetHintBits(tuple, buffer, HEAP_XMIN_COMMITTED,
- InvalidTransactionId);
- else
- {
- SetHintBits(tuple, buffer, HEAP_XMIN_INVALID,
- InvalidTransactionId);
- return false;
- }
- }
- }
- else if (TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetRawXmin(tuple)))
- =====================================================================
- Found a 50 line (205 tokens) duplication in the following files:
- Starting at line 884 of /home/shackle/pggit/postgresql/src/backend/executor/execTuples.c
- Starting at line 1277 of /home/shackle/pggit/postgresql/src/backend/access/common/heaptuple.c
- for (; attnum < natts; attnum++)
- {
- Form_pg_attribute thisatt = TupleDescAttr(tupleDesc, attnum);
- if (hasnulls && att_isnull(attnum, bp))
- {
- values[attnum] = (Datum) 0;
- isnull[attnum] = true;
- slow = true; /* can't use attcacheoff anymore */
- continue;
- }
- isnull[attnum] = false;
- if (!slow && thisatt->attcacheoff >= 0)
- off = thisatt->attcacheoff;
- else if (thisatt->attlen == -1)
- {
- /*
- * We can only cache the offset for a varlena attribute if the
- * offset is already suitably aligned, so that there would be no
- * pad bytes in any case: then the offset will be valid for either
- * an aligned or unaligned value.
- */
- if (!slow &&
- off == att_align_nominal(off, thisatt->attalign))
- thisatt->attcacheoff = off;
- else
- {
- off = att_align_pointer(off, thisatt->attalign, -1,
- tp + off);
- slow = true;
- }
- }
- else
- {
- /* not varlena, so safe to use att_align_nominal */
- off = att_align_nominal(off, thisatt->attalign);
- if (!slow)
- thisatt->attcacheoff = off;
- }
- values[attnum] = fetchatt(thisatt, tp + off);
- off = att_addlength_pointer(off, thisatt->attlen, tp + off);
- if (thisatt->attlen <= 0)
- slow = true; /* can't use attcacheoff anymore */
- }
- =====================================================================
- Found a 66 line (204 tokens) duplication in the following files:
- Starting at line 197 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-secure-openssl.c
- Starting at line 306 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-secure-openssl.c
- goto rloop;
- case SSL_ERROR_SYSCALL:
- if (n < 0)
- {
- result_errno = SOCK_ERRNO;
- if (result_errno == EPIPE ||
- result_errno == ECONNRESET)
- printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext(
- "server closed the connection unexpectedly\n"
- "\tThis probably means the server terminated abnormally\n"
- "\tbefore or while processing the request.\n"));
- else
- printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("SSL SYSCALL error: %s\n"),
- SOCK_STRERROR(result_errno,
- sebuf, sizeof(sebuf)));
- }
- else
- {
- printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("SSL SYSCALL error: EOF detected\n"));
- /* assume the connection is broken */
- result_errno = ECONNRESET;
- n = -1;
- }
- break;
- case SSL_ERROR_SSL:
- {
- char *errm = SSLerrmessage(ecode);
- printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("SSL error: %s\n"), errm);
- SSLerrfree(errm);
- /* assume the connection is broken */
- result_errno = ECONNRESET;
- n = -1;
- break;
- }
- case SSL_ERROR_ZERO_RETURN:
- /*
- * Per OpenSSL documentation, this error code is only returned for
- * a clean connection closure, so we should not report it as a
- * server crash.
- */
- printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("SSL connection has been closed unexpectedly\n"));
- result_errno = ECONNRESET;
- n = -1;
- break;
- default:
- printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("unrecognized SSL error code: %d\n"),
- err);
- /* assume the connection is broken */
- result_errno = ECONNRESET;
- n = -1;
- break;
- }
- /* ensure we return the intended errno to caller */
- SOCK_ERRNO_SET(result_errno);
- return n;
- }
- =====================================================================
- Found a 29 line (204 tokens) duplication in the following files:
- Starting at line 1498 of /home/shackle/pggit/postgresql/src/backend/utils/error/elog.c
- Starting at line 1678 of /home/shackle/pggit/postgresql/src/backend/utils/error/elog.c
- newedata = (ErrorData *) palloc(sizeof(ErrorData));
- memcpy(newedata, edata, sizeof(ErrorData));
- /* Make copies of separately-allocated fields */
- if (newedata->message)
- newedata->message = pstrdup(newedata->message);
- if (newedata->detail)
- newedata->detail = pstrdup(newedata->detail);
- if (newedata->detail_log)
- newedata->detail_log = pstrdup(newedata->detail_log);
- if (newedata->hint)
- newedata->hint = pstrdup(newedata->hint);
- if (newedata->context)
- newedata->context = pstrdup(newedata->context);
- if (newedata->schema_name)
- newedata->schema_name = pstrdup(newedata->schema_name);
- if (newedata->table_name)
- newedata->table_name = pstrdup(newedata->table_name);
- if (newedata->column_name)
- newedata->column_name = pstrdup(newedata->column_name);
- if (newedata->datatype_name)
- newedata->datatype_name = pstrdup(newedata->datatype_name);
- if (newedata->constraint_name)
- newedata->constraint_name = pstrdup(newedata->constraint_name);
- if (newedata->internalquery)
- newedata->internalquery = pstrdup(newedata->internalquery);
- /* Use the calling context for string allocation */
- newedata->assoc_context = CurrentMemoryContext;
- =====================================================================
- Found a 68 line (203 tokens) duplication in the following files:
- Starting at line 160 of /home/shackle/pggit/postgresql/src/test/examples/testlo64.c
- Starting at line 139 of /home/shackle/pggit/postgresql/src/test/examples/testlo.c
- fprintf(stderr, "error in lo_truncate64: %s", PQerrorMessage(conn));
- lo_close(conn, lobj_fd);
- }
- /*
- * exportFile -
- * export large object "lobjOid" to file "out_filename"
- *
- */
- static void
- exportFile(PGconn *conn, Oid lobjId, char *filename)
- {
- int lobj_fd;
- char buf[BUFSIZE];
- int nbytes,
- tmp;
- int fd;
- /*
- * open the large object
- */
- lobj_fd = lo_open(conn, lobjId, INV_READ);
- if (lobj_fd < 0)
- fprintf(stderr, "cannot open large object %u", lobjId);
- /*
- * open the file to be written to
- */
- fd = open(filename, O_CREAT | O_WRONLY | O_TRUNC, 0666);
- if (fd < 0)
- { /* error */
- fprintf(stderr, "cannot open unix file\"%s\"",
- filename);
- }
- /*
- * read in from the inversion file and write to the Unix file
- */
- while ((nbytes = lo_read(conn, lobj_fd, buf, BUFSIZE)) > 0)
- {
- tmp = write(fd, buf, nbytes);
- if (tmp < nbytes)
- {
- fprintf(stderr, "error while writing \"%s\"",
- filename);
- }
- }
- lo_close(conn, lobj_fd);
- close(fd);
- return;
- }
- static void
- exit_nicely(PGconn *conn)
- {
- PQfinish(conn);
- exit(1);
- }
- int
- main(int argc, char **argv)
- {
- char *in_filename,
- *out_filename,
- =====================================================================
- Found a 33 line (203 tokens) duplication in the following files:
- Starting at line 77 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.c
- Starting at line 135 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.c
- { 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);
- #line 33 "nan_test.pgc"
- if (sqlca.sqlcode < 0) sqlprint ( );}
- #line 33 "nan_test.pgc"
- /* declare cur cursor for select id , d , d from nantest1 */
- #line 35 "nan_test.pgc"
- { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur cursor for select id , d , d from nantest1", ECPGt_EOIT, ECPGt_EORT);
- #line 36 "nan_test.pgc"
- if (sqlca.sqlcode < 0) sqlprint ( );}
- #line 36 "nan_test.pgc"
- while (1)
- {
- { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch from cur", ECPGt_EOIT,
- ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_double,&(d),(long)1,(long)1,sizeof(double),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_char,(val),(long)16,(long)1,(16)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
- #line 39 "nan_test.pgc"
- if (sqlca.sqlcode < 0) sqlprint ( );}
- #line 39 "nan_test.pgc"
- if (sqlca.sqlcode)
- break;
- if (isnan(d))
- =====================================================================
- Found a 36 line (202 tokens) duplication in the following files:
- Starting at line 336 of /home/shackle/pggit/postgresql/src/backend/access/brin/brin_minmax.c
- Starting at line 668 of /home/shackle/pggit/postgresql/src/backend/access/brin/brin_inclusion.c
- for (i = 1; i <= BTMaxStrategyNumber; i++)
- opaque->strategy_procinfos[i - 1].fn_oid = InvalidOid;
- opaque->cached_subtype = subtype;
- }
- if (opaque->strategy_procinfos[strategynum - 1].fn_oid == InvalidOid)
- {
- Form_pg_attribute attr;
- HeapTuple tuple;
- Oid opfamily,
- oprid;
- bool isNull;
- opfamily = bdesc->bd_index->rd_opfamily[attno - 1];
- attr = TupleDescAttr(bdesc->bd_tupdesc, attno - 1);
- tuple = SearchSysCache4(AMOPSTRATEGY, ObjectIdGetDatum(opfamily),
- ObjectIdGetDatum(attr->atttypid),
- ObjectIdGetDatum(subtype),
- Int16GetDatum(strategynum));
- if (!HeapTupleIsValid(tuple))
- elog(ERROR, "missing operator %d(%u,%u) in opfamily %u",
- strategynum, attr->atttypid, subtype, opfamily);
- oprid = DatumGetObjectId(SysCacheGetAttr(AMOPSTRATEGY, tuple,
- Anum_pg_amop_amopopr, &isNull));
- ReleaseSysCache(tuple);
- Assert(!isNull && RegProcedureIsValid(oprid));
- fmgr_info_cxt(get_opcode(oprid),
- &opaque->strategy_procinfos[strategynum - 1],
- bdesc->bd_context);
- }
- return &opaque->strategy_procinfos[strategynum - 1];
- }
- =====================================================================
- Found a 39 line (200 tokens) duplication in the following files:
- Starting at line 1174 of /home/shackle/pggit/postgresql/src/backend/jit/llvm/llvmjit_expr.c
- Starting at line 1859 of /home/shackle/pggit/postgresql/src/backend/jit/llvm/llvmjit_expr.c
- case EEOP_CASE_TESTVAL:
- {
- LLVMBasicBlockRef b_avail,
- b_notavail;
- LLVMValueRef v_casevaluep,
- v_casevalue;
- LLVMValueRef v_casenullp,
- v_casenull;
- LLVMValueRef v_casevaluenull;
- b_avail = l_bb_before_v(opblocks[i + 1],
- "op.%d.avail", i);
- b_notavail = l_bb_before_v(opblocks[i + 1],
- "op.%d.notavail", i);
- v_casevaluep = l_ptr_const(op->d.casetest.value,
- l_ptr(TypeSizeT));
- v_casenullp = l_ptr_const(op->d.casetest.isnull,
- l_ptr(TypeStorageBool));
- v_casevaluenull =
- LLVMBuildICmp(b, LLVMIntEQ,
- LLVMBuildPtrToInt(b, v_casevaluep,
- TypeSizeT, ""),
- l_sizet_const(0), "");
- LLVMBuildCondBr(b, v_casevaluenull, b_notavail, b_avail);
- /* if casetest != NULL */
- LLVMPositionBuilderAtEnd(b, b_avail);
- v_casevalue = LLVMBuildLoad(b, v_casevaluep, "");
- v_casenull = LLVMBuildLoad(b, v_casenullp, "");
- LLVMBuildStore(b, v_casevalue, v_resvaluep);
- LLVMBuildStore(b, v_casenull, v_resnullp);
- LLVMBuildBr(b, opblocks[i + 1]);
- /* if casetest == NULL */
- LLVMPositionBuilderAtEnd(b, b_notavail);
- v_casevalue =
- l_load_struct_gep(b, v_econtext,
- =====================================================================
- Found a 36 line (198 tokens) duplication in the following files:
- Starting at line 123 of /home/shackle/pggit/postgresql/contrib/pgcrypto/crypt-gensalt.c
- Starting at line 403 of /home/shackle/pggit/postgresql/contrib/pgcrypto/crypt-blowfish.c
- static void
- BF_encode(char *dst, const BF_word *src, int size)
- {
- const unsigned char *sptr = (const unsigned char *) src;
- const unsigned char *end = sptr + size;
- unsigned char *dptr = (unsigned char *) dst;
- unsigned int c1,
- c2;
- do
- {
- c1 = *sptr++;
- *dptr++ = BF_itoa64[c1 >> 2];
- c1 = (c1 & 0x03) << 4;
- if (sptr >= end)
- {
- *dptr++ = BF_itoa64[c1];
- break;
- }
- c2 = *sptr++;
- c1 |= c2 >> 4;
- *dptr++ = BF_itoa64[c1];
- c1 = (c2 & 0x0f) << 2;
- if (sptr >= end)
- {
- *dptr++ = BF_itoa64[c1];
- break;
- }
- c2 = *sptr++;
- c1 |= c2 >> 6;
- *dptr++ = BF_itoa64[c1];
- *dptr++ = BF_itoa64[c2 & 0x3f];
- } while (sptr < end);
- }
- =====================================================================
- Found a 23 line (198 tokens) duplication in the following files:
- Starting at line 152 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-oldexec.c
- Starting at line 203 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-oldexec.c
- Starting at line 151 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-execute.c
- Starting at line 218 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-execute.c
- Starting at line 273 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-execute.c
- { ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "fetch 8 in CUR", ECPGt_EOIT,
- ECPGt_char,(name),(long)8,(long)8,(8)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_int,(amount),(long)1,(long)8,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_char,(letter),(long)1,(long)8,(1)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
- #line 54 "oldexec.pgc"
- if (sqlca.sqlcode < 0) sqlprint();}
- #line 54 "oldexec.pgc"
- for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
- {
- char n[8], l = letter[i][0];
- int a = amount[i];
- strncpy(n, name[i], 8);
- printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l);
- }
- { ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "close CUR", ECPGt_EOIT, ECPGt_EORT);
- =====================================================================
- Found a 30 line (196 tokens) duplication in the following files:
- Starting at line 52 of /home/shackle/pggit/postgresql/src/fe_utils/mbprint.c
- Starting at line 713 of /home/shackle/pggit/postgresql/src/backend/utils/mb/wchar.c
- static pg_wchar
- utf8_to_unicode(const unsigned char *c)
- {
- if ((*c & 0x80) == 0)
- return (pg_wchar) c[0];
- else if ((*c & 0xe0) == 0xc0)
- return (pg_wchar) (((c[0] & 0x1f) << 6) |
- (c[1] & 0x3f));
- else if ((*c & 0xf0) == 0xe0)
- return (pg_wchar) (((c[0] & 0x0f) << 12) |
- ((c[1] & 0x3f) << 6) |
- (c[2] & 0x3f));
- else if ((*c & 0xf8) == 0xf0)
- return (pg_wchar) (((c[0] & 0x07) << 18) |
- ((c[1] & 0x3f) << 12) |
- ((c[2] & 0x3f) << 6) |
- (c[3] & 0x3f));
- else
- /* that is an invalid code on purpose */
- return 0xffffffff;
- }
- /*
- * Unicode 3.1 compliant validation : for each category, it checks the
- * combination of each byte to make sure it maps to a valid range. It also
- * returns -1 for the following UCS values: ucs > 0x10ffff ucs & 0xfffe =
- * 0xfffe 0xfdd0 < ucs < 0xfdef ucs & 0xdb00 = 0xd800 (surrogates)
- */
- static int
- =====================================================================
- Found a 13 line (196 tokens) duplication in the following files:
- Starting at line 239 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-array.c
- Starting at line 294 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-array.c
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_short,(a),(long)1,(long)10,sizeof(short),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_char,&(t),(long)0,(long)1,(1)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_timestamp,&(ts),(long)1,(long)10,sizeof(timestamp),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_numeric,&(n),(long)1,(long)10,sizeof(numeric),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_date,&(d),(long)1,(long)10,sizeof(date),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_interval,&(in),(long)1,(long)10,sizeof(interval),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
- =====================================================================
- Found a 48 line (194 tokens) duplication in the following files:
- Starting at line 142 of /home/shackle/pggit/postgresql/src/backend/utils/adt/oracle_compat.c
- Starting at line 240 of /home/shackle/pggit/postgresql/src/backend/utils/adt/oracle_compat.c
- lpad(PG_FUNCTION_ARGS)
- {
- text *string1 = PG_GETARG_TEXT_PP(0);
- int32 len = PG_GETARG_INT32(1);
- text *string2 = PG_GETARG_TEXT_PP(2);
- text *ret;
- char *ptr1,
- *ptr2,
- *ptr2start,
- *ptr2end,
- *ptr_ret;
- int m,
- s1len,
- s2len;
- int bytelen;
- /* Negative len is silently taken as zero */
- if (len < 0)
- len = 0;
- s1len = VARSIZE_ANY_EXHDR(string1);
- if (s1len < 0)
- s1len = 0; /* shouldn't happen */
- s2len = VARSIZE_ANY_EXHDR(string2);
- if (s2len < 0)
- s2len = 0; /* shouldn't happen */
- s1len = pg_mbstrlen_with_len(VARDATA_ANY(string1), s1len);
- if (s1len > len)
- s1len = len; /* truncate string1 to len chars */
- if (s2len <= 0)
- len = s1len; /* nothing to pad with, so don't pad */
- bytelen = pg_database_encoding_max_length() * len;
- /* check for integer overflow */
- if (len != 0 && bytelen / pg_database_encoding_max_length() != len)
- ereport(ERROR,
- (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
- errmsg("requested length too large")));
- ret = (text *) palloc(VARHDRSZ + bytelen);
- m = len - s1len;
- =====================================================================
- Found a 29 line (193 tokens) duplication in the following files:
- Starting at line 1577 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_dumpall.c
- Starting at line 94 of /home/shackle/pggit/postgresql/src/bin/pg_basebackup/streamutil.c
- exit_nicely(1);
- }
- for (conn_opt = conn_opts; conn_opt->keyword != NULL; conn_opt++)
- {
- if (conn_opt->val != NULL && conn_opt->val[0] != '\0' &&
- strcmp(conn_opt->keyword, "dbname") != 0)
- argcount++;
- }
- keywords = pg_malloc0((argcount + 1) * sizeof(*keywords));
- values = pg_malloc0((argcount + 1) * sizeof(*values));
- for (conn_opt = conn_opts; conn_opt->keyword != NULL; conn_opt++)
- {
- if (conn_opt->val != NULL && conn_opt->val[0] != '\0' &&
- strcmp(conn_opt->keyword, "dbname") != 0)
- {
- keywords[i] = conn_opt->keyword;
- values[i] = conn_opt->val;
- i++;
- }
- }
- }
- else
- {
- keywords = pg_malloc0((argcount + 1) * sizeof(*keywords));
- values = pg_malloc0((argcount + 1) * sizeof(*values));
- }
- =====================================================================
- Found a 26 line (193 tokens) duplication in the following files:
- Starting at line 1346 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
- Starting at line 1665 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
- InitFunctionCallInfoData(fcinfo, flinfo, 9, collation, NULL, NULL);
- fcinfo.arg[0] = arg1;
- fcinfo.arg[1] = arg2;
- fcinfo.arg[2] = arg3;
- fcinfo.arg[3] = arg4;
- fcinfo.arg[4] = arg5;
- fcinfo.arg[5] = arg6;
- fcinfo.arg[6] = arg7;
- fcinfo.arg[7] = arg8;
- fcinfo.arg[8] = arg9;
- fcinfo.argnull[0] = false;
- fcinfo.argnull[1] = false;
- fcinfo.argnull[2] = false;
- fcinfo.argnull[3] = false;
- fcinfo.argnull[4] = false;
- fcinfo.argnull[5] = false;
- fcinfo.argnull[6] = false;
- fcinfo.argnull[7] = false;
- fcinfo.argnull[8] = false;
- result = FunctionCallInvoke(&fcinfo);
- /* Check for null result, since caller is clearly not expecting one */
- if (fcinfo.isnull)
- elog(ERROR, "function %u returned NULL", fcinfo.flinfo->fn_oid);
- =====================================================================
- Found a 18 line (192 tokens) duplication in the following files:
- Starting at line 864 of /home/shackle/pggit/postgresql/contrib/pg_trgm/trgm_gist.c
- Starting at line 711 of /home/shackle/pggit/postgresql/src/backend/utils/adt/tsgistidx.c
- datum_r = (TRGM *) palloc(CALCGTSIZE(SIGNKEY, 0));
- SET_VARSIZE(datum_r, CALCGTSIZE(SIGNKEY, 0));
- datum_r->flag = SIGNKEY;
- memcpy((void *) GETSIGN(datum_r), (void *) cache[seed_2].sign, sizeof(BITVEC));
- }
- union_l = GETSIGN(datum_l);
- union_r = GETSIGN(datum_r);
- maxoff = OffsetNumberNext(maxoff);
- fillcache(&cache[maxoff], GETENTRY(entryvec, maxoff));
- /* sort before ... */
- costvector = (SPLITCOST *) palloc(sizeof(SPLITCOST) * maxoff);
- for (j = FirstOffsetNumber; j <= maxoff; j = OffsetNumberNext(j))
- {
- costvector[j - 1].pos = j;
- size_alpha = hemdistcache(&(cache[seed_1]), &(cache[j]));
- size_beta = hemdistcache(&(cache[seed_2]), &(cache[j]));
- costvector[j - 1].cost = abs(size_alpha - size_beta);
- =====================================================================
- Found a 63 line (192 tokens) duplication in the following files:
- Starting at line 114 of /home/shackle/pggit/postgresql/src/backend/utils/adt/varbit.c
- Starting at line 430 of /home/shackle/pggit/postgresql/src/backend/utils/adt/varbit.c
- bit_in(PG_FUNCTION_ARGS)
- {
- char *input_string = PG_GETARG_CSTRING(0);
- #ifdef NOT_USED
- Oid typelem = PG_GETARG_OID(1);
- #endif
- int32 atttypmod = PG_GETARG_INT32(2);
- VarBit *result; /* The resulting bit string */
- char *sp; /* pointer into the character string */
- bits8 *r; /* pointer into the result */
- int len, /* Length of the whole data structure */
- bitlen, /* Number of bits in the bit string */
- slen; /* Length of the input string */
- bool bit_not_hex; /* false = hex string true = bit string */
- int bc;
- bits8 x = 0;
- /* Check that the first character is a b or an x */
- if (input_string[0] == 'b' || input_string[0] == 'B')
- {
- bit_not_hex = true;
- sp = input_string + 1;
- }
- else if (input_string[0] == 'x' || input_string[0] == 'X')
- {
- bit_not_hex = false;
- sp = input_string + 1;
- }
- else
- {
- /*
- * Otherwise it's binary. This allows things like cast('1001' as bit)
- * to work transparently.
- */
- bit_not_hex = true;
- sp = input_string;
- }
- /*
- * Determine bitlength from input string. MaxAllocSize ensures a regular
- * input is small enough, but we must check hex input.
- */
- slen = strlen(sp);
- if (bit_not_hex)
- bitlen = slen;
- else
- {
- if (slen > VARBITMAXLEN / 4)
- ereport(ERROR,
- (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
- errmsg("bit string length exceeds the maximum allowed (%d)",
- VARBITMAXLEN)));
- bitlen = slen * 4;
- }
- /*
- * Sometimes atttypmod is not supplied. If it is supplied we need to make
- * sure that the bitstring fits.
- */
- if (atttypmod <= 0)
- atttypmod = bitlen;
- else if (bitlen != atttypmod)
- =====================================================================
- Found a 37 line (191 tokens) duplication in the following files:
- Starting at line 54 of /home/shackle/pggit/postgresql/src/backend/access/brin/brin_validate.c
- Starting at line 54 of /home/shackle/pggit/postgresql/src/backend/access/nbtree/nbtvalidate.c
- OpFamilyOpFuncGroup *opclassgroup;
- int i;
- ListCell *lc;
- /* Fetch opclass information */
- classtup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclassoid));
- if (!HeapTupleIsValid(classtup))
- elog(ERROR, "cache lookup failed for operator class %u", opclassoid);
- classform = (Form_pg_opclass) GETSTRUCT(classtup);
- opfamilyoid = classform->opcfamily;
- opcintype = classform->opcintype;
- opclassname = NameStr(classform->opcname);
- /* Fetch opfamily information */
- familytup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfamilyoid));
- if (!HeapTupleIsValid(familytup))
- elog(ERROR, "cache lookup failed for operator family %u", opfamilyoid);
- familyform = (Form_pg_opfamily) GETSTRUCT(familytup);
- opfamilyname = NameStr(familyform->opfname);
- /* Fetch all operators and support functions of the opfamily */
- oprlist = SearchSysCacheList1(AMOPSTRATEGY, ObjectIdGetDatum(opfamilyoid));
- proclist = SearchSysCacheList1(AMPROCNUM, ObjectIdGetDatum(opfamilyoid));
- /* Check individual support functions */
- for (i = 0; i < proclist->n_members; i++)
- {
- HeapTuple proctup = &proclist->members[i]->tuple;
- Form_pg_amproc procform = (Form_pg_amproc) GETSTRUCT(proctup);
- bool ok;
- /* Check procedure numbers and function signatures */
- switch (procform->amprocnum)
- {
- case BRIN_PROCNUM_OPCINFO:
- =====================================================================
- Found a 42 line (190 tokens) duplication in the following files:
- Starting at line 584 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/dt_common.c
- Starting at line 274 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
- int
- date2j(int y, int m, int d)
- {
- int julian;
- int century;
- if (m > 2)
- {
- m += 1;
- y += 4800;
- }
- else
- {
- m += 13;
- y += 4799;
- }
- century = y / 100;
- julian = y * 365 - 32167;
- julian += y / 4 - century + century / 4;
- julian += 7834 * m / 256 + d;
- return julian;
- } /* date2j() */
- void
- j2date(int jd, int *year, int *month, int *day)
- {
- unsigned int julian;
- unsigned int quad;
- unsigned int extra;
- int y;
- julian = jd;
- julian += 32044;
- quad = julian / 146097;
- extra = (julian - quad * 146097) * 4 + 3;
- julian += 60 + quad * 3 + extra / 146097;
- quad = julian / 1461;
- julian -= quad * 1461;
- y = julian * 4 / 1461;
- julian = ((y != 0) ? (julian + 305) % 365 : (julian + 306) % 366) + 123;
- =====================================================================
- Found a 42 line (190 tokens) duplication in the following files:
- Starting at line 814 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/dt_common.c
- Starting at line 860 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/dt_common.c
- sprintf(str + 5, "/%04d %02d:%02d",
- (tm->tm_year > 0) ? tm->tm_year : -(tm->tm_year - 1),
- tm->tm_hour, tm->tm_min);
- /*
- * Print fractional seconds if any. The field widths here should
- * be at least equal to MAX_TIMESTAMP_PRECISION.
- */
- if (fsec != 0)
- {
- sprintf(str + strlen(str), ":%02d.%06d", tm->tm_sec, fsec);
- TrimTrailingZeros(str);
- }
- else
- sprintf(str + strlen(str), ":%02d", tm->tm_sec);
- if (tm->tm_year <= 0)
- sprintf(str + strlen(str), " BC");
- /*
- * Note: the uses of %.*s in this function would be risky if the
- * timezone names ever contain non-ASCII characters. However, all
- * TZ abbreviations in the IANA database are plain ASCII.
- */
- if (print_tz)
- {
- if (tzn)
- sprintf(str + strlen(str), " %.*s", MAXTZLEN, tzn);
- else
- {
- hour = -(tz / SECS_PER_HOUR);
- min = (abs(tz) / MINS_PER_HOUR) % MINS_PER_HOUR;
- if (min != 0)
- sprintf(str + strlen(str), "%+03d:%02d", hour, min);
- else
- sprintf(str + strlen(str), "%+03d", hour);
- }
- }
- break;
- case USE_GERMAN_DATES:
- =====================================================================
- Found a 19 line (190 tokens) duplication in the following files:
- Starting at line 231 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 371 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 539 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
- ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
- #line 78 "cursor.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 78 "cursor.pgc"
- printf("%d %s\n", id, t);
- strcpy(msg, "fetch :count from");
- count = 1;
- { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 from $0",
- ECPGt_int,&(count),(long)1,(long)1,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
- =====================================================================
- Found a 19 line (190 tokens) duplication in the following files:
- Starting at line 274 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 418 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 582 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
- ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
- #line 90 "cursor.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 90 "cursor.pgc"
- printf("%d %s\n", id, t);
- strcpy(msg, "fetch :count");
- count = 1;
- { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 $0",
- ECPGt_int,&(count),(long)1,(long)1,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
- =====================================================================
- Found a 64 line (189 tokens) duplication in the following files:
- Starting at line 9493 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_dump.c
- Starting at line 14954 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_dump.c
- high = &comments[ncomments - 1];
- while (low <= high)
- {
- middle = low + (high - low) / 2;
- if (classoid < middle->classoid)
- high = middle - 1;
- else if (classoid > middle->classoid)
- low = middle + 1;
- else if (objoid < middle->objoid)
- high = middle - 1;
- else if (objoid > middle->objoid)
- low = middle + 1;
- else
- break; /* found a match */
- }
- if (low > high) /* no matches */
- {
- *items = NULL;
- return 0;
- }
- /*
- * Now determine how many items match the object. The search loop
- * invariant still holds: only items between low and high inclusive could
- * match.
- */
- nmatch = 1;
- while (middle > low)
- {
- if (classoid != middle[-1].classoid ||
- objoid != middle[-1].objoid)
- break;
- middle--;
- nmatch++;
- }
- *items = middle;
- middle += nmatch;
- while (middle <= high)
- {
- if (classoid != middle->classoid ||
- objoid != middle->objoid)
- break;
- middle++;
- nmatch++;
- }
- return nmatch;
- }
- /*
- * collectComments --
- *
- * Construct a table of all comments available for database objects.
- * We used to do per-object queries for the comments, but it's much faster
- * to pull them all over at once, and on most databases the memory cost
- * isn't high.
- *
- * The table is sorted by classoid/objid/objsubid for speed in lookup.
- */
- static int
- =====================================================================
- Found a 59 line (189 tokens) duplication in the following files:
- Starting at line 1330 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
- Starting at line 2187 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
- return DTERR_BAD_FORMAT;
- /***
- * We will need one of the following fields:
- * DTK_NUMBER should be hhmmss.fff
- * DTK_TIME should be hh:mm:ss.fff
- * DTK_DATE should be hhmmss-zz
- ***/
- if (i >= nf - 1 ||
- (ftype[i + 1] != DTK_NUMBER &&
- ftype[i + 1] != DTK_TIME &&
- ftype[i + 1] != DTK_DATE))
- return DTERR_BAD_FORMAT;
- ptype = val;
- break;
- case UNKNOWN_FIELD:
- /*
- * Before giving up and declaring error, check to see
- * if it is an all-alpha timezone name.
- */
- namedTz = pg_tzset(field[i]);
- if (!namedTz)
- return DTERR_BAD_FORMAT;
- /* we'll apply the zone setting below */
- tmask = DTK_M(TZ);
- break;
- default:
- return DTERR_BAD_FORMAT;
- }
- break;
- default:
- return DTERR_BAD_FORMAT;
- }
- if (tmask & fmask)
- return DTERR_BAD_FORMAT;
- fmask |= tmask;
- } /* end loop over fields */
- /* do final checking/adjustment of Y/M/D fields */
- dterr = ValidateDate(fmask, isjulian, is2digits, bc, tm);
- if (dterr)
- return dterr;
- /* handle AM/PM */
- if (mer != HR24 && tm->tm_hour > HOURS_PER_DAY / 2)
- return DTERR_FIELD_OVERFLOW;
- if (mer == AM && tm->tm_hour == HOURS_PER_DAY / 2)
- tm->tm_hour = 0;
- else if (mer == PM && tm->tm_hour != HOURS_PER_DAY / 2)
- tm->tm_hour += HOURS_PER_DAY / 2;
- /* do additional checking for full date specs... */
- if (*dtype == DTK_DATE)
- =====================================================================
- Found a 52 line (189 tokens) duplication in the following files:
- Starting at line 703 of /home/shackle/pggit/postgresql/src/backend/access/heap/heapam.c
- Starting at line 993 of /home/shackle/pggit/postgresql/src/backend/access/heap/heapam.c
- if (backward)
- {
- finished = (page == scan->rs_startblock) ||
- (scan->rs_numblocks != InvalidBlockNumber ? --scan->rs_numblocks == 0 : false);
- if (page == 0)
- page = scan->rs_nblocks;
- page--;
- }
- else if (scan->rs_parallel != NULL)
- {
- page = heap_parallelscan_nextpage(scan);
- finished = (page == InvalidBlockNumber);
- }
- else
- {
- page++;
- if (page >= scan->rs_nblocks)
- page = 0;
- finished = (page == scan->rs_startblock) ||
- (scan->rs_numblocks != InvalidBlockNumber ? --scan->rs_numblocks == 0 : false);
- /*
- * Report our new scan position for synchronization purposes. We
- * don't do that when moving backwards, however. That would just
- * mess up any other forward-moving scanners.
- *
- * Note: we do this before checking for end of scan so that the
- * final state of the position hint is back at the start of the
- * rel. That's not strictly necessary, but otherwise when you run
- * the same query multiple times the starting position would shift
- * a little bit backwards on every invocation, which is confusing.
- * We don't guarantee any specific ordering in general, though.
- */
- if (scan->rs_syncscan)
- ss_report_location(scan->rs_rd, page);
- }
- /*
- * return NULL if we've exhausted all the pages
- */
- if (finished)
- {
- if (BufferIsValid(scan->rs_cbuf))
- ReleaseBuffer(scan->rs_cbuf);
- scan->rs_cbuf = InvalidBuffer;
- scan->rs_cblock = InvalidBlockNumber;
- tuple->t_data = NULL;
- scan->rs_inited = false;
- return;
- }
- heapgetpage(scan, page);
- =====================================================================
- Found a 43 line (188 tokens) duplication in the following files:
- Starting at line 5584 of /home/shackle/pggit/postgresql/src/backend/utils/adt/formatting.c
- Starting at line 5694 of /home/shackle/pggit/postgresql/src/backend/utils/adt/formatting.c
- if (*orgnum == '-')
- {
- sign = '-';
- orgnum++;
- }
- else
- sign = '+';
- numstr_pre_len = strlen(orgnum);
- /* post-decimal digits? Pad out with zeros. */
- if (Num.post)
- {
- numstr = (char *) palloc(numstr_pre_len + Num.post + 2);
- strcpy(numstr, orgnum);
- *(numstr + numstr_pre_len) = '.';
- memset(numstr + numstr_pre_len + 1, '0', Num.post);
- *(numstr + numstr_pre_len + Num.post + 1) = '\0';
- }
- else
- numstr = orgnum;
- /* needs padding? */
- if (numstr_pre_len < Num.pre)
- out_pre_spaces = Num.pre - numstr_pre_len;
- /* overflowed prefix digit format? */
- else if (numstr_pre_len > Num.pre)
- {
- numstr = (char *) palloc(Num.pre + Num.post + 2);
- fill_str(numstr, '#', Num.pre + Num.post + 1);
- *(numstr + Num.pre) = '.';
- }
- }
- NUM_TOCHAR_finish;
- PG_RETURN_TEXT_P(result);
- }
- /* ---------------
- * INT8 to_char()
- * ---------------
- */
- Datum
- =====================================================================
- Found a 42 line (188 tokens) duplication in the following files:
- Starting at line 2170 of /home/shackle/pggit/postgresql/src/backend/commands/analyze.c
- Starting at line 2535 of /home/shackle/pggit/postgresql/src/backend/commands/analyze.c
- if (track_cnt < track_max && toowide_cnt == 0 &&
- stats->stadistinct > 0 &&
- track_cnt <= num_mcv)
- {
- /* Track list includes all values seen, and all will fit */
- num_mcv = track_cnt;
- }
- else
- {
- int *mcv_counts;
- /* Incomplete list; decide how many values are worth keeping */
- if (num_mcv > track_cnt)
- num_mcv = track_cnt;
- if (num_mcv > 0)
- {
- mcv_counts = (int *) palloc(num_mcv * sizeof(int));
- for (i = 0; i < num_mcv; i++)
- mcv_counts[i] = track[i].count;
- num_mcv = analyze_mcv_list(mcv_counts, num_mcv,
- stats->stadistinct,
- stats->stanullfrac,
- samplerows, totalrows);
- }
- }
- /* Generate MCV slot entry */
- if (num_mcv > 0)
- {
- MemoryContext old_context;
- Datum *mcv_values;
- float4 *mcv_freqs;
- /* Must copy the target values into anl_context */
- old_context = MemoryContextSwitchTo(stats->anl_context);
- mcv_values = (Datum *) palloc(num_mcv * sizeof(Datum));
- mcv_freqs = (float4 *) palloc(num_mcv * sizeof(float4));
- for (i = 0; i < num_mcv; i++)
- {
- mcv_values[i] = datumCopy(track[i].value,
- =====================================================================
- Found a 15 line (185 tokens) duplication in the following files:
- Starting at line 1737 of /home/shackle/pggit/postgresql/src/backend/utils/mb/wchar.c
- Starting at line 1751 of /home/shackle/pggit/postgresql/src/backend/utils/mb/wchar.c
- {pg_mule2wchar_with_len, pg_wchar2mule_with_len, pg_mule_mblen, pg_mule_dsplen, pg_mule_verifier, 4}, /* PG_MULE_INTERNAL */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN1 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN2 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN3 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN4 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN5 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN6 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN7 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN8 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN9 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN10 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_WIN1256 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_WIN1258 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_WIN866 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_WIN874 */
- =====================================================================
- Found a 34 line (184 tokens) duplication in the following files:
- Starting at line 698 of /home/shackle/pggit/postgresql/src/backend/utils/adt/array_userfuncs.c
- Starting at line 837 of /home/shackle/pggit/postgresql/src/backend/utils/adt/array_userfuncs.c
- my_extra = (ArrayMetaState *) fcinfo->flinfo->fn_extra;
- if (my_extra == NULL)
- {
- fcinfo->flinfo->fn_extra = MemoryContextAlloc(fcinfo->flinfo->fn_mcxt,
- sizeof(ArrayMetaState));
- my_extra = (ArrayMetaState *) fcinfo->flinfo->fn_extra;
- my_extra->element_type = ~element_type;
- }
- if (my_extra->element_type != element_type)
- {
- get_typlenbyvalalign(element_type,
- &my_extra->typlen,
- &my_extra->typbyval,
- &my_extra->typalign);
- typentry = lookup_type_cache(element_type, TYPECACHE_EQ_OPR_FINFO);
- if (!OidIsValid(typentry->eq_opr_finfo.fn_oid))
- ereport(ERROR,
- (errcode(ERRCODE_UNDEFINED_FUNCTION),
- errmsg("could not identify an equality operator for type %s",
- format_type_be(element_type))));
- my_extra->element_type = element_type;
- fmgr_info_cxt(typentry->eq_opr_finfo.fn_oid, &my_extra->proc,
- fcinfo->flinfo->fn_mcxt);
- }
- /* Examine each array element until we find a match. */
- array_iterator = array_create_iterator(array, 0, my_extra);
- while (array_iterate(array_iterator, &value, &isnull))
- {
- position++;
- =====================================================================
- Found a 47 line (184 tokens) duplication in the following files:
- Starting at line 880 of /home/shackle/pggit/postgresql/src/backend/access/brin/brin.c
- Starting at line 957 of /home/shackle/pggit/postgresql/src/backend/access/brin/brin.c
- if (heapBlk64 > BRIN_ALL_BLOCKRANGES || heapBlk64 < 0)
- {
- char *blk = psprintf(INT64_FORMAT, heapBlk64);
- ereport(ERROR,
- (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
- errmsg("block number out of range: %s", blk)));
- }
- heapBlk = (BlockNumber) heapBlk64;
- /*
- * We must lock table before index to avoid deadlocks. However, if the
- * passed indexoid isn't an index then IndexGetRelation() will fail.
- * Rather than emitting a not-very-helpful error message, postpone
- * complaining, expecting that the is-it-an-index test below will fail.
- */
- heapoid = IndexGetRelation(indexoid, true);
- if (OidIsValid(heapoid))
- heapRel = heap_open(heapoid, ShareUpdateExclusiveLock);
- else
- heapRel = NULL;
- indexRel = index_open(indexoid, ShareUpdateExclusiveLock);
- /* Must be a BRIN index */
- if (indexRel->rd_rel->relkind != RELKIND_INDEX ||
- indexRel->rd_rel->relam != BRIN_AM_OID)
- ereport(ERROR,
- (errcode(ERRCODE_WRONG_OBJECT_TYPE),
- errmsg("\"%s\" is not a BRIN index",
- RelationGetRelationName(indexRel))));
- /* User must own the index (comparable to privileges needed for VACUUM) */
- if (!pg_class_ownercheck(indexoid, GetUserId()))
- aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_INDEX,
- RelationGetRelationName(indexRel));
- /*
- * Since we did the IndexGetRelation call above without any lock, it's
- * barely possible that a race against an index drop/recreation could have
- * netted us the wrong table. Recheck.
- */
- if (heapRel == NULL || heapoid != IndexGetRelation(indexoid, false))
- ereport(ERROR,
- (errcode(ERRCODE_UNDEFINED_TABLE),
- errmsg("could not open parent table of index %s",
- RelationGetRelationName(indexRel))));
- =====================================================================
- Found a 36 line (183 tokens) duplication in the following files:
- Starting at line 299 of /home/shackle/pggit/postgresql/contrib/ltree/_ltree_gist.c
- Starting at line 351 of /home/shackle/pggit/postgresql/contrib/intarray/_intbig_gist.c
- ltree_gist *_k,
- *_j;
- maxoff = entryvec->n - 2;
- nbytes = (maxoff + 2) * sizeof(OffsetNumber);
- v->spl_left = (OffsetNumber *) palloc(nbytes);
- v->spl_right = (OffsetNumber *) palloc(nbytes);
- for (k = FirstOffsetNumber; k < maxoff; k = OffsetNumberNext(k))
- {
- _k = GETENTRY(entryvec, k);
- for (j = OffsetNumberNext(k); j <= maxoff; j = OffsetNumberNext(j))
- {
- size_waste = hemdist(_k, GETENTRY(entryvec, j));
- if (size_waste > waste)
- {
- waste = size_waste;
- seed_1 = k;
- seed_2 = j;
- }
- }
- }
- left = v->spl_left;
- v->spl_nleft = 0;
- right = v->spl_right;
- v->spl_nright = 0;
- if (seed_1 == 0 || seed_2 == 0)
- {
- seed_1 = 1;
- seed_2 = 2;
- }
- /* form initial .. */
- if (LTG_ISALLTRUE(GETENTRY(entryvec, seed_1)))
- =====================================================================
- Found a 36 line (182 tokens) duplication in the following files:
- Starting at line 59 of /home/shackle/pggit/postgresql/contrib/pgcrypto/pgp-armor.c
- Starting at line 232 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- buf |= *s << (pos << 3);
- pos--;
- s++;
- /*
- * write it out
- */
- if (pos < 0)
- {
- *p++ = _base64[(buf >> 18) & 0x3f];
- *p++ = _base64[(buf >> 12) & 0x3f];
- *p++ = _base64[(buf >> 6) & 0x3f];
- *p++ = _base64[buf & 0x3f];
- pos = 2;
- buf = 0;
- }
- if (p >= lend)
- {
- *p++ = '\n';
- lend = p + 76;
- }
- }
- if (pos != 2)
- {
- *p++ = _base64[(buf >> 18) & 0x3f];
- *p++ = _base64[(buf >> 12) & 0x3f];
- *p++ = (pos == 0) ? _base64[(buf >> 6) & 0x3f] : '=';
- *p++ = '=';
- }
- return p - dst;
- }
- /* probably should use lookup table */
- static int
- =====================================================================
- Found a 39 line (180 tokens) duplication in the following files:
- Starting at line 142 of /home/shackle/pggit/postgresql/src/bin/pg_upgrade/version.c
- Starting at line 243 of /home/shackle/pggit/postgresql/src/bin/pg_upgrade/version.c
- " c.relnamespace = n.oid AND "
- /* exclude possible orphaned temp tables */
- " n.nspname !~ '^pg_temp_' AND "
- " n.nspname !~ '^pg_toast_temp_' AND "
- " n.nspname NOT IN ('pg_catalog', 'information_schema')");
- ntups = PQntuples(res);
- i_nspname = PQfnumber(res, "nspname");
- i_relname = PQfnumber(res, "relname");
- i_attname = PQfnumber(res, "attname");
- for (rowno = 0; rowno < ntups; rowno++)
- {
- found = true;
- if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
- pg_fatal("could not open file \"%s\": %s\n", output_path,
- strerror(errno));
- if (!db_used)
- {
- fprintf(script, "Database: %s\n", active_db->db_name);
- db_used = true;
- }
- fprintf(script, " %s.%s.%s\n",
- PQgetvalue(res, rowno, i_nspname),
- PQgetvalue(res, rowno, i_relname),
- PQgetvalue(res, rowno, i_attname));
- }
- PQclear(res);
- PQfinish(conn);
- }
- if (script)
- fclose(script);
- if (found)
- {
- pg_log(PG_REPORT, "fatal\n");
- pg_fatal("Your installation contains the \"line\" data type in user tables. This\n"
- =====================================================================
- Found a 31 line (180 tokens) duplication in the following files:
- Starting at line 54 of /home/shackle/pggit/postgresql/src/backend/access/brin/brin_validate.c
- Starting at line 54 of /home/shackle/pggit/postgresql/src/backend/access/nbtree/nbtvalidate.c
- Starting at line 59 of /home/shackle/pggit/postgresql/src/backend/access/hash/hashvalidate.c
- OpFamilyOpFuncGroup *opclassgroup;
- int i;
- ListCell *lc;
- /* Fetch opclass information */
- classtup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclassoid));
- if (!HeapTupleIsValid(classtup))
- elog(ERROR, "cache lookup failed for operator class %u", opclassoid);
- classform = (Form_pg_opclass) GETSTRUCT(classtup);
- opfamilyoid = classform->opcfamily;
- opcintype = classform->opcintype;
- opclassname = NameStr(classform->opcname);
- /* Fetch opfamily information */
- familytup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfamilyoid));
- if (!HeapTupleIsValid(familytup))
- elog(ERROR, "cache lookup failed for operator family %u", opfamilyoid);
- familyform = (Form_pg_opfamily) GETSTRUCT(familytup);
- opfamilyname = NameStr(familyform->opfname);
- /* Fetch all operators and support functions of the opfamily */
- oprlist = SearchSysCacheList1(AMOPSTRATEGY, ObjectIdGetDatum(opfamilyoid));
- proclist = SearchSysCacheList1(AMPROCNUM, ObjectIdGetDatum(opfamilyoid));
- /* Check individual support functions */
- for (i = 0; i < proclist->n_members; i++)
- {
- HeapTuple proctup = &proclist->members[i]->tuple;
- Form_pg_amproc procform = (Form_pg_amproc) GETSTRUCT(proctup);
- =====================================================================
- Found a 40 line (179 tokens) duplication in the following files:
- Starting at line 763 of /home/shackle/pggit/postgresql/src/backend/utils/adt/jsonfuncs.c
- Starting at line 881 of /home/shackle/pggit/postgresql/src/backend/utils/adt/jsonfuncs.c
- VARSIZE_ANY_EXHDR(key));
- if (v != NULL)
- {
- text *result = NULL;
- switch (v->type)
- {
- case jbvNull:
- break;
- case jbvBool:
- result = cstring_to_text(v->val.boolean ? "true" : "false");
- break;
- case jbvString:
- result = cstring_to_text_with_len(v->val.string.val, v->val.string.len);
- break;
- case jbvNumeric:
- result = cstring_to_text(DatumGetCString(DirectFunctionCall1(numeric_out,
- PointerGetDatum(v->val.numeric))));
- break;
- case jbvBinary:
- {
- StringInfo jtext = makeStringInfo();
- (void) JsonbToCString(jtext, v->val.binary.data, -1);
- result = cstring_to_text_with_len(jtext->data, jtext->len);
- }
- break;
- default:
- elog(ERROR, "unrecognized jsonb type: %d", (int) v->type);
- }
- if (result)
- PG_RETURN_TEXT_P(result);
- }
- PG_RETURN_NULL();
- }
- Datum
- =====================================================================
- Found a 61 line (178 tokens) duplication in the following files:
- Starting at line 1618 of /home/shackle/pggit/postgresql/contrib/dblink/dblink.c
- Starting at line 1786 of /home/shackle/pggit/postgresql/contrib/dblink/dblink.c
- dblink_build_sql_insert(PG_FUNCTION_ARGS)
- {
- text *relname_text = PG_GETARG_TEXT_PP(0);
- int2vector *pkattnums_arg = (int2vector *) PG_GETARG_POINTER(1);
- int32 pknumatts_arg = PG_GETARG_INT32(2);
- ArrayType *src_pkattvals_arry = PG_GETARG_ARRAYTYPE_P(3);
- ArrayType *tgt_pkattvals_arry = PG_GETARG_ARRAYTYPE_P(4);
- Relation rel;
- int *pkattnums;
- int pknumatts;
- char **src_pkattvals;
- char **tgt_pkattvals;
- int src_nitems;
- int tgt_nitems;
- char *sql;
- /*
- * Open target relation.
- */
- rel = get_rel_from_relname(relname_text, AccessShareLock, ACL_SELECT);
- /*
- * Process pkattnums argument.
- */
- validate_pkattnums(rel, pkattnums_arg, pknumatts_arg,
- &pkattnums, &pknumatts);
- /*
- * Source array is made up of key values that will be used to locate the
- * tuple of interest from the local system.
- */
- src_pkattvals = get_text_array_contents(src_pkattvals_arry, &src_nitems);
- /*
- * There should be one source array key value for each key attnum
- */
- if (src_nitems != pknumatts)
- ereport(ERROR,
- (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
- errmsg("source key array length must match number of key " \
- "attributes")));
- /*
- * Target array is made up of key values that will be used to build the
- * SQL string for use on the remote system.
- */
- tgt_pkattvals = get_text_array_contents(tgt_pkattvals_arry, &tgt_nitems);
- /*
- * There should be one target array key value for each key attnum
- */
- if (tgt_nitems != pknumatts)
- ereport(ERROR,
- (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
- errmsg("target key array length must match number of key " \
- "attributes")));
- /*
- * Prep work is finally done. Go get the SQL string.
- */
- sql = get_sql_insert(rel, pkattnums, pknumatts, src_pkattvals, tgt_pkattvals);
- =====================================================================
- Found a 35 line (177 tokens) duplication in the following files:
- Starting at line 1035 of /home/shackle/pggit/postgresql/src/bin/pg_upgrade/check.c
- Starting at line 1126 of /home/shackle/pggit/postgresql/src/bin/pg_upgrade/check.c
- Starting at line 146 of /home/shackle/pggit/postgresql/src/bin/pg_upgrade/version.c
- Starting at line 247 of /home/shackle/pggit/postgresql/src/bin/pg_upgrade/version.c
- " n.nspname NOT IN ('pg_catalog', 'information_schema')");
- ntups = PQntuples(res);
- i_nspname = PQfnumber(res, "nspname");
- i_relname = PQfnumber(res, "relname");
- i_attname = PQfnumber(res, "attname");
- for (rowno = 0; rowno < ntups; rowno++)
- {
- found = true;
- if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
- pg_fatal("could not open file \"%s\": %s\n",
- output_path, strerror(errno));
- if (!db_used)
- {
- fprintf(script, "Database: %s\n", active_db->db_name);
- db_used = true;
- }
- fprintf(script, " %s.%s.%s\n",
- PQgetvalue(res, rowno, i_nspname),
- PQgetvalue(res, rowno, i_relname),
- PQgetvalue(res, rowno, i_attname));
- }
- PQclear(res);
- PQfinish(conn);
- }
- if (script)
- fclose(script);
- if (found)
- {
- pg_log(PG_REPORT, "fatal\n");
- pg_fatal("Your installation contains one of the reg* data types in user tables.\n"
- =====================================================================
- Found a 35 line (177 tokens) duplication in the following files:
- Starting at line 1530 of /home/shackle/pggit/postgresql/src/backend/utils/adt/varbit.c
- Starting at line 1610 of /home/shackle/pggit/postgresql/src/backend/utils/adt/varbit.c
- srcbitsleft = 32;
- /* drop any input bits that don't fit */
- srcbitsleft = Min(srcbitsleft, destbitsleft);
- /* sign-fill any excess bytes in output */
- while (destbitsleft >= srcbitsleft + 8)
- {
- *r++ = (bits8) ((a < 0) ? BITMASK : 0);
- destbitsleft -= 8;
- }
- /* store first fractional byte */
- if (destbitsleft > srcbitsleft)
- {
- unsigned int val = (unsigned int) (a >> (destbitsleft - 8));
- /* Force sign-fill in case the compiler implements >> as zero-fill */
- if (a < 0)
- val |= ((unsigned int) -1) << (srcbitsleft + 8 - destbitsleft);
- *r++ = (bits8) (val & BITMASK);
- destbitsleft -= 8;
- }
- /* Now srcbitsleft and destbitsleft are the same, need not track both */
- /* store whole bytes */
- while (destbitsleft >= 8)
- {
- *r++ = (bits8) ((a >> (destbitsleft - 8)) & BITMASK);
- destbitsleft -= 8;
- }
- /* store last fractional byte */
- if (destbitsleft > 0)
- *r = (bits8) ((a << (8 - destbitsleft)) & BITMASK);
- PG_RETURN_VARBIT_P(result);
- }
- Datum
- =====================================================================
- Found a 48 line (177 tokens) duplication in the following files:
- Starting at line 2543 of /home/shackle/pggit/postgresql/src/backend/commands/trigger.c
- Starting at line 2632 of /home/shackle/pggit/postgresql/src/backend/commands/trigger.c
- TRIGGER_TYPE_BEFORE,
- TRIGGER_TYPE_INSERT))
- continue;
- if (!TriggerEnabled(estate, relinfo, trigger, LocTriggerData.tg_event,
- NULL, NULL, newtuple))
- continue;
- LocTriggerData.tg_trigtuple = oldtuple = newtuple;
- LocTriggerData.tg_trigtuplebuf = InvalidBuffer;
- LocTriggerData.tg_trigger = trigger;
- newtuple = ExecCallTriggerFunc(&LocTriggerData,
- i,
- relinfo->ri_TrigFunctions,
- relinfo->ri_TrigInstrument,
- GetPerTupleMemoryContext(estate));
- if (oldtuple != newtuple && oldtuple != slottuple)
- heap_freetuple(oldtuple);
- if (newtuple == NULL)
- {
- if (should_free)
- heap_freetuple(slottuple);
- return NULL; /* "do nothing" */
- }
- }
- if (newtuple != slottuple)
- {
- /*
- * Return the modified tuple using the es_trig_tuple_slot. We assume
- * the tuple was allocated in per-tuple memory context, and therefore
- * will go away by itself. The tuple table slot should not try to
- * clear it.
- */
- TupleTableSlot *newslot = estate->es_trig_tuple_slot;
- TupleDesc tupdesc = RelationGetDescr(relinfo->ri_RelationDesc);
- if (newslot->tts_tupleDescriptor != tupdesc)
- ExecSetSlotDescriptor(newslot, tupdesc);
- ExecStoreHeapTuple(newtuple, newslot, false);
- slot = newslot;
- }
- if (should_free)
- heap_freetuple(slottuple);
- return slot;
- }
- void
- =====================================================================
- Found a 24 line (175 tokens) duplication in the following files:
- Starting at line 1309 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
- Starting at line 1625 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
- InitFunctionCallInfoData(fcinfo, flinfo, 8, collation, NULL, NULL);
- fcinfo.arg[0] = arg1;
- fcinfo.arg[1] = arg2;
- fcinfo.arg[2] = arg3;
- fcinfo.arg[3] = arg4;
- fcinfo.arg[4] = arg5;
- fcinfo.arg[5] = arg6;
- fcinfo.arg[6] = arg7;
- fcinfo.arg[7] = arg8;
- fcinfo.argnull[0] = false;
- fcinfo.argnull[1] = false;
- fcinfo.argnull[2] = false;
- fcinfo.argnull[3] = false;
- fcinfo.argnull[4] = false;
- fcinfo.argnull[5] = false;
- fcinfo.argnull[6] = false;
- fcinfo.argnull[7] = false;
- result = FunctionCallInvoke(&fcinfo);
- /* Check for null result, since caller is clearly not expecting one */
- if (fcinfo.isnull)
- elog(ERROR, "function %u returned NULL", fcinfo.flinfo->fn_oid);
- =====================================================================
- Found a 22 line (174 tokens) duplication in the following files:
- Starting at line 1026 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
- Starting at line 1346 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
- Starting at line 1665 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
- InitFunctionCallInfoData(fcinfo, NULL, 9, collation, NULL, NULL);
- fcinfo.arg[0] = arg1;
- fcinfo.arg[1] = arg2;
- fcinfo.arg[2] = arg3;
- fcinfo.arg[3] = arg4;
- fcinfo.arg[4] = arg5;
- fcinfo.arg[5] = arg6;
- fcinfo.arg[6] = arg7;
- fcinfo.arg[7] = arg8;
- fcinfo.arg[8] = arg9;
- fcinfo.argnull[0] = false;
- fcinfo.argnull[1] = false;
- fcinfo.argnull[2] = false;
- fcinfo.argnull[3] = false;
- fcinfo.argnull[4] = false;
- fcinfo.argnull[5] = false;
- fcinfo.argnull[6] = false;
- fcinfo.argnull[7] = false;
- fcinfo.argnull[8] = false;
- result = (*func) (&fcinfo);
- =====================================================================
- Found a 37 line (173 tokens) duplication in the following files:
- Starting at line 158 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/interval.c
- Starting at line 3553 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
- tm->tm_mon += (fval * 12);
- break;
- case 'M':
- tm->tm_mon += val;
- AdjustFractDays(fval, tm, fsec, DAYS_PER_MONTH);
- break;
- case 'W':
- tm->tm_mday += val * 7;
- AdjustFractDays(fval, tm, fsec, 7);
- break;
- case 'D':
- tm->tm_mday += val;
- AdjustFractSeconds(fval, tm, fsec, SECS_PER_DAY);
- break;
- case 'T': /* ISO 8601 4.4.3.3 Alternative Format / Basic */
- case '\0':
- if (ISO8601IntegerWidth(fieldstart) == 8 && !havefield)
- {
- tm->tm_year += val / 10000;
- tm->tm_mon += (val / 100) % 100;
- tm->tm_mday += val % 100;
- AdjustFractSeconds(fval, tm, fsec, SECS_PER_DAY);
- if (unit == '\0')
- return 0;
- datepart = false;
- havefield = false;
- continue;
- }
- /* Else fall through to extended alternative format */
- /* FALLTHROUGH */
- case '-': /* ISO 8601 4.4.3.3 Alternative Format,
- * Extended */
- if (havefield)
- return DTERR_BAD_FORMAT;
- tm->tm_year += val;
- tm->tm_mon += (fval * 12);
- =====================================================================
- Found a 33 line (172 tokens) duplication in the following files:
- Starting at line 694 of /home/shackle/pggit/postgresql/contrib/dblink/dblink.c
- Starting at line 1401 of /home/shackle/pggit/postgresql/contrib/dblink/dblink.c
- if (PG_NARGS() == 3)
- {
- /* text,text,bool */
- conname = text_to_cstring(PG_GETARG_TEXT_PP(0));
- sql = text_to_cstring(PG_GETARG_TEXT_PP(1));
- fail = PG_GETARG_BOOL(2);
- dblink_get_conn(conname, &conn, &conname, &freeconn);
- }
- else if (PG_NARGS() == 2)
- {
- /* text,text or text,bool */
- if (get_fn_expr_argtype(fcinfo->flinfo, 1) == BOOLOID)
- {
- sql = text_to_cstring(PG_GETARG_TEXT_PP(0));
- fail = PG_GETARG_BOOL(1);
- conn = pconn->conn;
- }
- else
- {
- conname = text_to_cstring(PG_GETARG_TEXT_PP(0));
- sql = text_to_cstring(PG_GETARG_TEXT_PP(1));
- dblink_get_conn(conname, &conn, &conname, &freeconn);
- }
- }
- else if (PG_NARGS() == 1)
- {
- /* text */
- conn = pconn->conn;
- sql = text_to_cstring(PG_GETARG_TEXT_PP(0));
- }
- else
- /* shouldn't happen */
- elog(ERROR, "wrong number of arguments");
- =====================================================================
- Found a 48 line (172 tokens) duplication in the following files:
- Starting at line 883 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
- Starting at line 1127 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
- Oid collation;
- /*
- * Skip dropped columns
- */
- if (i1 < ncolumns1 && TupleDescAttr(tupdesc1, i1)->attisdropped)
- {
- i1++;
- continue;
- }
- if (i2 < ncolumns2 && TupleDescAttr(tupdesc2, i2)->attisdropped)
- {
- i2++;
- continue;
- }
- if (i1 >= ncolumns1 || i2 >= ncolumns2)
- break; /* we'll deal with mismatch below loop */
- att1 = TupleDescAttr(tupdesc1, i1);
- att2 = TupleDescAttr(tupdesc2, i2);
- /*
- * Have two matching columns, they must be same type
- */
- if (att1->atttypid != att2->atttypid)
- ereport(ERROR,
- (errcode(ERRCODE_DATATYPE_MISMATCH),
- errmsg("cannot compare dissimilar column types %s and %s at record column %d",
- format_type_be(att1->atttypid),
- format_type_be(att2->atttypid),
- j + 1)));
- /*
- * If they're not same collation, we don't complain here, but the
- * comparison function might.
- */
- collation = att1->attcollation;
- if (collation != att2->attcollation)
- collation = InvalidOid;
- /*
- * Lookup the comparison function if not done already
- */
- typentry = my_extra->columns[j].typentry;
- if (typentry == NULL ||
- typentry->type_id != att1->atttypid)
- {
- typentry = lookup_type_cache(att1->atttypid,
- =====================================================================
- Found a 14 line (171 tokens) duplication in the following files:
- Starting at line 1737 of /home/shackle/pggit/postgresql/src/backend/utils/mb/wchar.c
- Starting at line 1752 of /home/shackle/pggit/postgresql/src/backend/utils/mb/wchar.c
- {pg_mule2wchar_with_len, pg_wchar2mule_with_len, pg_mule_mblen, pg_mule_dsplen, pg_mule_verifier, 4}, /* PG_MULE_INTERNAL */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN1 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN2 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN3 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN4 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN5 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN6 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN7 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN8 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN9 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN10 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_WIN1256 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_WIN1258 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_WIN866 */
- =====================================================================
- Found a 52 line (171 tokens) duplication in the following files:
- Starting at line 4549 of /home/shackle/pggit/postgresql/src/backend/utils/adt/timestamp.c
- Starting at line 4765 of /home/shackle/pggit/postgresql/src/backend/utils/adt/timestamp.c
- case DTK_MICROSEC:
- result = tm->tm_sec * 1000000.0 + fsec;
- break;
- case DTK_MILLISEC:
- result = tm->tm_sec * 1000.0 + fsec / 1000.0;
- break;
- case DTK_SECOND:
- result = tm->tm_sec + fsec / 1000000.0;
- break;
- case DTK_MINUTE:
- result = tm->tm_min;
- break;
- case DTK_HOUR:
- result = tm->tm_hour;
- break;
- case DTK_DAY:
- result = tm->tm_mday;
- break;
- case DTK_MONTH:
- result = tm->tm_mon;
- break;
- case DTK_QUARTER:
- result = (tm->tm_mon - 1) / 3 + 1;
- break;
- case DTK_WEEK:
- result = (float8) date2isoweek(tm->tm_year, tm->tm_mon, tm->tm_mday);
- break;
- case DTK_YEAR:
- if (tm->tm_year > 0)
- result = tm->tm_year;
- else
- /* there is no year 0, just 1 BC and 1 AD */
- result = tm->tm_year - 1;
- break;
- case DTK_DECADE:
- /*
- * what is a decade wrt dates? let us assume that decade 199
- * is 1990 thru 1999... decade 0 starts on year 1 BC, and -1
- * is 11 BC thru 2 BC...
- */
- if (tm->tm_year >= 0)
- =====================================================================
- Found a 34 line (170 tokens) duplication in the following files:
- Starting at line 360 of /home/shackle/pggit/postgresql/contrib/hstore/hstore_gist.c
- Starting at line 302 of /home/shackle/pggit/postgresql/contrib/ltree/_ltree_gist.c
- *_j;
- nbytes = (maxoff + 2) * sizeof(OffsetNumber);
- v->spl_left = (OffsetNumber *) palloc(nbytes);
- v->spl_right = (OffsetNumber *) palloc(nbytes);
- for (k = FirstOffsetNumber; k < maxoff; k = OffsetNumberNext(k))
- {
- _k = GETENTRY(entryvec, k);
- for (j = OffsetNumberNext(k); j <= maxoff; j = OffsetNumberNext(j))
- {
- size_waste = hemdist(_k, GETENTRY(entryvec, j));
- if (size_waste > waste)
- {
- waste = size_waste;
- seed_1 = k;
- seed_2 = j;
- }
- }
- }
- left = v->spl_left;
- v->spl_nleft = 0;
- right = v->spl_right;
- v->spl_nright = 0;
- if (seed_1 == 0 || seed_2 == 0)
- {
- seed_1 = 1;
- seed_2 = 2;
- }
- /* form initial .. */
- if (ISALLTRUE(GETENTRY(entryvec, seed_1)))
- =====================================================================
- Found a 46 line (170 tokens) duplication in the following files:
- Starting at line 33 of /home/shackle/pggit/postgresql/src/test/examples/testlo64.c
- Starting at line 33 of /home/shackle/pggit/postgresql/src/test/examples/testlo.c
- static Oid
- importFile(PGconn *conn, char *filename)
- {
- Oid lobjId;
- int lobj_fd;
- char buf[BUFSIZE];
- int nbytes,
- tmp;
- int fd;
- /*
- * open the file to be read in
- */
- fd = open(filename, O_RDONLY, 0666);
- if (fd < 0)
- { /* error */
- fprintf(stderr, "cannot open unix file\"%s\"\n", filename);
- }
- /*
- * create the large object
- */
- lobjId = lo_creat(conn, INV_READ | INV_WRITE);
- if (lobjId == 0)
- fprintf(stderr, "cannot create large object");
- lobj_fd = lo_open(conn, lobjId, INV_WRITE);
- /*
- * read in from the Unix file and write to the inversion file
- */
- while ((nbytes = read(fd, buf, BUFSIZE)) > 0)
- {
- tmp = lo_write(conn, lobj_fd, buf, nbytes);
- if (tmp < nbytes)
- fprintf(stderr, "error while reading \"%s\"", filename);
- }
- close(fd);
- lo_close(conn, lobj_fd);
- return lobjId;
- }
- static void
- pickout(PGconn *conn, Oid lobjId, pg_int64 start, int len)
- =====================================================================
- Found a 26 line (170 tokens) duplication in the following files:
- Starting at line 899 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/interval.c
- Starting at line 4374 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
- AppendSeconds(cp, sec, fsec, MAX_INTERVAL_PRECISION, true);
- }
- break;
- /* Compatible with postgresql < 8.4 when DateStyle != 'iso' */
- case INTSTYLE_POSTGRES_VERBOSE:
- default:
- strcpy(cp, "@");
- cp++;
- cp = AddVerboseIntPart(cp, year, "year", &is_zero, &is_before);
- cp = AddVerboseIntPart(cp, mon, "mon", &is_zero, &is_before);
- cp = AddVerboseIntPart(cp, mday, "day", &is_zero, &is_before);
- cp = AddVerboseIntPart(cp, hour, "hour", &is_zero, &is_before);
- cp = AddVerboseIntPart(cp, min, "min", &is_zero, &is_before);
- if (sec != 0 || fsec != 0)
- {
- *cp++ = ' ';
- if (sec < 0 || (sec == 0 && fsec < 0))
- {
- if (is_zero)
- is_before = true;
- else if (!is_before)
- *cp++ = '-';
- }
- else if (is_before)
- *cp++ = '-';
- =====================================================================
- Found a 41 line (170 tokens) duplication in the following files:
- Starting at line 1156 of /home/shackle/pggit/postgresql/src/backend/storage/lmgr/lock.c
- Starting at line 4100 of /home/shackle/pggit/postgresql/src/backend/storage/lmgr/lock.c
- LOCK_PRINT("LockAcquire: found", lock, lockmode);
- Assert((lock->nRequested >= 0) && (lock->requested[lockmode] >= 0));
- Assert((lock->nGranted >= 0) && (lock->granted[lockmode] >= 0));
- Assert(lock->nGranted <= lock->nRequested);
- }
- /*
- * Create the hash key for the proclock table.
- */
- proclocktag.myLock = lock;
- proclocktag.myProc = proc;
- proclock_hashcode = ProcLockHashCode(&proclocktag, hashcode);
- /*
- * Find or create a proclock entry with this tag
- */
- proclock = (PROCLOCK *) hash_search_with_hash_value(LockMethodProcLockHash,
- (void *) &proclocktag,
- proclock_hashcode,
- HASH_ENTER_NULL,
- &found);
- if (!proclock)
- {
- /* Oops, not enough shmem for the proclock */
- if (lock->nRequested == 0)
- {
- /*
- * There are no other requestors of this lock, so garbage-collect
- * the lock object. We *must* do this to avoid a permanent leak
- * of shared memory, because there won't be anything to cause
- * anyone to release the lock object later.
- */
- Assert(SHMQueueEmpty(&(lock->procLocks)));
- if (!hash_search_with_hash_value(LockMethodLockHash,
- (void *) &(lock->tag),
- hashcode,
- HASH_REMOVE,
- NULL))
- elog(PANIC, "lock table corrupted");
- }
- =====================================================================
- Found a 48 line (170 tokens) duplication in the following files:
- Starting at line 367 of /home/shackle/pggit/postgresql/src/backend/access/common/indextuple.c
- Starting at line 570 of /home/shackle/pggit/postgresql/src/backend/access/common/heaptuple.c
- if (IndexTupleHasNulls(tup) && att_isnull(i, bp))
- {
- usecache = false;
- continue; /* this cannot be the target att */
- }
- /* If we know the next offset, we can skip the rest */
- if (usecache && att->attcacheoff >= 0)
- off = att->attcacheoff;
- else if (att->attlen == -1)
- {
- /*
- * We can only cache the offset for a varlena attribute if the
- * offset is already suitably aligned, so that there would be
- * no pad bytes in any case: then the offset will be valid for
- * either an aligned or unaligned value.
- */
- if (usecache &&
- off == att_align_nominal(off, att->attalign))
- att->attcacheoff = off;
- else
- {
- off = att_align_pointer(off, att->attalign, -1,
- tp + off);
- usecache = false;
- }
- }
- else
- {
- /* not varlena, so safe to use att_align_nominal */
- off = att_align_nominal(off, att->attalign);
- if (usecache)
- att->attcacheoff = off;
- }
- if (i == attnum)
- break;
- off = att_addlength_pointer(off, att->attlen, tp + off);
- if (usecache && att->attlen <= 0)
- usecache = false;
- }
- }
- return fetchatt(TupleDescAttr(tupleDesc, attnum), tp + off);
- }
- =====================================================================
- Found a 53 line (169 tokens) duplication in the following files:
- Starting at line 372 of /home/shackle/pggit/postgresql/src/backend/utils/time/tqual.c
- Starting at line 748 of /home/shackle/pggit/postgresql/src/backend/utils/time/tqual.c
- Assert(htup->t_tableOid != InvalidOid);
- if (!HeapTupleHeaderXminCommitted(tuple))
- {
- if (HeapTupleHeaderXminInvalid(tuple))
- return false;
- /* Used by pre-9.0 binary upgrades */
- if (tuple->t_infomask & HEAP_MOVED_OFF)
- {
- TransactionId xvac = HeapTupleHeaderGetXvac(tuple);
- if (TransactionIdIsCurrentTransactionId(xvac))
- return false;
- if (!TransactionIdIsInProgress(xvac))
- {
- if (TransactionIdDidCommit(xvac))
- {
- SetHintBits(tuple, buffer, HEAP_XMIN_INVALID,
- InvalidTransactionId);
- return false;
- }
- SetHintBits(tuple, buffer, HEAP_XMIN_COMMITTED,
- InvalidTransactionId);
- }
- }
- /* Used by pre-9.0 binary upgrades */
- else if (tuple->t_infomask & HEAP_MOVED_IN)
- {
- TransactionId xvac = HeapTupleHeaderGetXvac(tuple);
- if (!TransactionIdIsCurrentTransactionId(xvac))
- {
- if (TransactionIdIsInProgress(xvac))
- return false;
- if (TransactionIdDidCommit(xvac))
- SetHintBits(tuple, buffer, HEAP_XMIN_COMMITTED,
- InvalidTransactionId);
- else
- {
- SetHintBits(tuple, buffer, HEAP_XMIN_INVALID,
- InvalidTransactionId);
- return false;
- }
- }
- }
- /*
- * An invalid Xmin can be left behind by a speculative insertion that
- * is canceled by super-deleting the tuple. This also applies to
- * TOAST tuples created during speculative insertion.
- */
- else if (!TransactionIdIsValid(HeapTupleHeaderGetXmin(tuple)))
- =====================================================================
- Found a 17 line (168 tokens) duplication in the following files:
- Starting at line 246 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 289 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 from $0",
- ECPGt_int,&(count),(long)1,(long)1,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
- ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
- #line 83 "cursor.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 83 "cursor.pgc"
- printf("%d %s\n", id, t);
- strcpy(msg, "move in");
- =====================================================================
- Found a 17 line (168 tokens) duplication in the following files:
- Starting at line 386 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 433 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 from $0",
- ECPGt_int,&(count),(long)1,(long)1,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
- ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
- #line 124 "cursor.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 124 "cursor.pgc"
- printf("%d %s\n", id, t);
- strcpy(msg, "move");
- =====================================================================
- Found a 17 line (168 tokens) duplication in the following files:
- Starting at line 554 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 597 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 from $0",
- ECPGt_int,&(count),(long)1,(long)1,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
- ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
- #line 170 "cursor.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 170 "cursor.pgc"
- printf("%d %s\n", id, t);
- strcpy(msg, "move");
- =====================================================================
- Found a 35 line (168 tokens) duplication in the following files:
- Starting at line 889 of /home/shackle/pggit/postgresql/src/backend/utils/mmgr/mcxt.c
- Starting at line 992 of /home/shackle/pggit/postgresql/src/backend/utils/mmgr/mcxt.c
- void *ret;
- AssertArg(MemoryContextIsValid(context));
- AssertNotInCriticalSection(context);
- if (((flags & MCXT_ALLOC_HUGE) != 0 && !AllocHugeSizeIsValid(size)) ||
- ((flags & MCXT_ALLOC_HUGE) == 0 && !AllocSizeIsValid(size)))
- elog(ERROR, "invalid memory alloc request size %zu", size);
- context->isReset = false;
- ret = context->methods->alloc(context, size);
- if (unlikely(ret == NULL))
- {
- if ((flags & MCXT_ALLOC_NO_OOM) == 0)
- {
- MemoryContextStats(TopMemoryContext);
- ereport(ERROR,
- (errcode(ERRCODE_OUT_OF_MEMORY),
- errmsg("out of memory"),
- errdetail("Failed on request of size %zu in memory context \"%s\".",
- size, context->name)));
- }
- return NULL;
- }
- VALGRIND_MEMPOOL_ALLOC(context, ret, size);
- if ((flags & MCXT_ALLOC_ZERO) != 0)
- MemSetAligned(ret, 0, size);
- return ret;
- }
- void *
- =====================================================================
- Found a 18 line (167 tokens) duplication in the following files:
- Starting at line 231 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 371 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 539 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 709 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
- ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
- #line 78 "cursor.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 78 "cursor.pgc"
- printf("%d %s\n", id, t);
- strcpy(msg, "fetch :count from");
- count = 1;
- { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 from $0",
- ECPGt_int,&(count),(long)1,(long)1,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- =====================================================================
- Found a 18 line (167 tokens) duplication in the following files:
- Starting at line 274 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 418 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 582 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 752 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
- ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
- #line 90 "cursor.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 90 "cursor.pgc"
- printf("%d %s\n", id, t);
- strcpy(msg, "fetch :count");
- count = 1;
- { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 $0",
- ECPGt_int,&(count),(long)1,(long)1,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- =====================================================================
- Found a 32 line (167 tokens) duplication in the following files:
- Starting at line 111 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
- Starting at line 328 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
- Starting at line 484 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
- Starting at line 675 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
- ncolumns = tupdesc->natts;
- /*
- * We arrange to look up the needed I/O info just once per series of
- * calls, assuming the record type doesn't change underneath us.
- */
- my_extra = (RecordIOData *) fcinfo->flinfo->fn_extra;
- if (my_extra == NULL ||
- my_extra->ncolumns != ncolumns)
- {
- fcinfo->flinfo->fn_extra =
- MemoryContextAlloc(fcinfo->flinfo->fn_mcxt,
- offsetof(RecordIOData, columns) +
- ncolumns * sizeof(ColumnIOData));
- my_extra = (RecordIOData *) fcinfo->flinfo->fn_extra;
- my_extra->record_type = InvalidOid;
- my_extra->record_typmod = 0;
- }
- if (my_extra->record_type != tupType ||
- my_extra->record_typmod != tupTypmod)
- {
- MemSet(my_extra, 0,
- offsetof(RecordIOData, columns) +
- ncolumns * sizeof(ColumnIOData));
- my_extra->record_type = tupType;
- my_extra->record_typmod = tupTypmod;
- my_extra->ncolumns = ncolumns;
- }
- values = (Datum *) palloc(ncolumns * sizeof(Datum));
- nulls = (bool *) palloc(ncolumns * sizeof(bool));
- =====================================================================
- Found a 25 line (166 tokens) duplication in the following files:
- Starting at line 4765 of /home/shackle/pggit/postgresql/src/backend/utils/adt/ruleutils.c
- Starting at line 4948 of /home/shackle/pggit/postgresql/src/backend/utils/adt/ruleutils.c
- rulename = NameStr(*(DatumGetName(dat)));
- fno = SPI_fnumber(rulettc, "ev_type");
- dat = SPI_getbinval(ruletup, rulettc, fno, &isnull);
- Assert(!isnull);
- ev_type = DatumGetChar(dat);
- fno = SPI_fnumber(rulettc, "ev_class");
- dat = SPI_getbinval(ruletup, rulettc, fno, &isnull);
- Assert(!isnull);
- ev_class = DatumGetObjectId(dat);
- fno = SPI_fnumber(rulettc, "is_instead");
- dat = SPI_getbinval(ruletup, rulettc, fno, &isnull);
- Assert(!isnull);
- is_instead = DatumGetBool(dat);
- /* these could be nulls */
- fno = SPI_fnumber(rulettc, "ev_qual");
- ev_qual = SPI_getvalue(ruletup, rulettc, fno);
- fno = SPI_fnumber(rulettc, "ev_action");
- ev_action = SPI_getvalue(ruletup, rulettc, fno);
- if (ev_action != NULL)
- actions = (List *) stringToNode(ev_action);
- =====================================================================
- Found a 17 line (165 tokens) duplication in the following files:
- Starting at line 724 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 767 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 from $0",
- ECPGt_int,&(count),(long)1,(long)1,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
- ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
- #line 222 "cursor.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 222 "cursor.pgc"
- printf("%d %s\n", id, t);
- strcpy(msg, "move");
- =====================================================================
- Found a 17 line (164 tokens) duplication in the following files:
- Starting at line 221 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-array.c
- Starting at line 242 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-array.c
- ECPGt_char,(text),(long)25,(long)1,(25)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_timestamp,&(ts),(long)1,(long)10,sizeof(timestamp),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_numeric,&(n),(long)1,(long)10,sizeof(numeric),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_date,&(d),(long)1,(long)10,sizeof(date),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_interval,&(in),(long)1,(long)10,sizeof(interval),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
- #line 63 "array.pgc"
- if (sqlca.sqlcode < 0) sqlprint();}
- #line 63 "array.pgc"
- { 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 )",
- =====================================================================
- Found a 49 line (162 tokens) duplication in the following files:
- Starting at line 1788 of /home/shackle/pggit/postgresql/contrib/postgres_fdw/postgres_fdw.c
- Starting at line 1863 of /home/shackle/pggit/postgresql/contrib/postgres_fdw/postgres_fdw.c
- p_values = convert_prep_stmt_params(fmstate, NULL, slot);
- /*
- * Execute the prepared statement.
- */
- if (!PQsendQueryPrepared(fmstate->conn,
- fmstate->p_name,
- fmstate->p_nums,
- p_values,
- NULL,
- NULL,
- 0))
- pgfdw_report_error(ERROR, NULL, fmstate->conn, false, fmstate->query);
- /*
- * Get the result, and check for success.
- *
- * We don't use a PG_TRY block here, so be careful not to throw error
- * without releasing the PGresult.
- */
- res = pgfdw_get_result(fmstate->conn, fmstate->query);
- if (PQresultStatus(res) !=
- (fmstate->has_returning ? PGRES_TUPLES_OK : PGRES_COMMAND_OK))
- pgfdw_report_error(ERROR, res, fmstate->conn, true, fmstate->query);
- /* Check number of rows affected, and fetch RETURNING tuple if any */
- if (fmstate->has_returning)
- {
- n_rows = PQntuples(res);
- if (n_rows > 0)
- store_returning_result(fmstate, slot, res);
- }
- else
- n_rows = atoi(PQcmdTuples(res));
- /* And clean up */
- PQclear(res);
- MemoryContextReset(fmstate->temp_cxt);
- /* Return NULL if nothing was inserted on the remote end */
- return (n_rows > 0) ? slot : NULL;
- }
- /*
- * postgresExecForeignUpdate
- * Update one row in a foreign table
- */
- static TupleTableSlot *
- =====================================================================
- Found a 48 line (162 tokens) duplication in the following files:
- Starting at line 1986 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/dt_common.c
- Starting at line 1005 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
- Starting at line 1912 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
- return -1;
- switch (ptype)
- {
- case DTK_YEAR:
- tm->tm_year = val;
- tmask = DTK_M(YEAR);
- break;
- case DTK_MONTH:
- /*
- * already have a month and hour? then assume
- * minutes
- */
- if ((fmask & DTK_M(MONTH)) != 0 &&
- (fmask & DTK_M(HOUR)) != 0)
- {
- tm->tm_min = val;
- tmask = DTK_M(MINUTE);
- }
- else
- {
- tm->tm_mon = val;
- tmask = DTK_M(MONTH);
- }
- break;
- case DTK_DAY:
- tm->tm_mday = val;
- tmask = DTK_M(DAY);
- break;
- case DTK_HOUR:
- tm->tm_hour = val;
- tmask = DTK_M(HOUR);
- break;
- case DTK_MINUTE:
- tm->tm_min = val;
- tmask = DTK_M(MINUTE);
- break;
- case DTK_SECOND:
- tm->tm_sec = val;
- tmask = DTK_M(SECOND);
- if (*cp == '.')
- {
- =====================================================================
- Found a 16 line (162 tokens) duplication in the following files:
- Starting at line 203 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-array.c
- Starting at line 222 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-array.c
- { 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 )",
- ECPGt_timestamp,&(ts),(long)1,(long)10,sizeof(timestamp),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_numeric,&(n),(long)1,(long)10,sizeof(numeric),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_date,&(d),(long)1,(long)10,sizeof(date),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_interval,&(in),(long)1,(long)10,sizeof(interval),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
- #line 61 "array.pgc"
- if (sqlca.sqlcode < 0) sqlprint();}
- #line 61 "array.pgc"
- { 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 )",
- =====================================================================
- Found a 29 line (161 tokens) duplication in the following files:
- Starting at line 1272 of /home/shackle/pggit/postgresql/contrib/hstore/hstore_io.c
- Starting at line 1327 of /home/shackle/pggit/postgresql/contrib/hstore/hstore_io.c
- hstore_to_json_loose(PG_FUNCTION_ARGS)
- {
- HStore *in = PG_GETARG_HSTORE_P(0);
- int i;
- int count = HS_COUNT(in);
- char *base = STRPTR(in);
- HEntry *entries = ARRPTR(in);
- StringInfoData tmp,
- dst;
- if (count == 0)
- PG_RETURN_TEXT_P(cstring_to_text_with_len("{}", 2));
- initStringInfo(&tmp);
- initStringInfo(&dst);
- appendStringInfoChar(&dst, '{');
- for (i = 0; i < count; i++)
- {
- resetStringInfo(&tmp);
- appendBinaryStringInfo(&tmp, HSTORE_KEY(entries, base, i),
- HSTORE_KEYLEN(entries, i));
- escape_json(&dst, tmp.data);
- appendStringInfoString(&dst, ": ");
- if (HSTORE_VALISNULL(entries, i))
- appendStringInfoString(&dst, "null");
- /* guess that values of 't' or 'f' are booleans */
- else if (HSTORE_VALLEN(entries, i) == 1 &&
- =====================================================================
- Found a 26 line (161 tokens) duplication in the following files:
- Starting at line 852 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/interval.c
- Starting at line 4321 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
- AppendSeconds(cp, sec, fsec, MAX_INTERVAL_PRECISION, true);
- }
- }
- break;
- /* ISO 8601 "time-intervals by duration only" */
- case INTSTYLE_ISO_8601:
- /* special-case zero to avoid printing nothing */
- if (year == 0 && mon == 0 && mday == 0 &&
- hour == 0 && min == 0 && sec == 0 && fsec == 0)
- {
- sprintf(cp, "PT0S");
- break;
- }
- *cp++ = 'P';
- cp = AddISO8601IntPart(cp, year, 'Y');
- cp = AddISO8601IntPart(cp, mon, 'M');
- cp = AddISO8601IntPart(cp, mday, 'D');
- if (hour != 0 || min != 0 || sec != 0 || fsec != 0)
- *cp++ = 'T';
- cp = AddISO8601IntPart(cp, hour, 'H');
- cp = AddISO8601IntPart(cp, min, 'M');
- if (sec != 0 || fsec != 0)
- {
- if (sec < 0 || fsec < 0)
- *cp++ = '-';
- =====================================================================
- Found a 20 line (161 tokens) duplication in the following files:
- Starting at line 2834 of /home/shackle/pggit/postgresql/src/backend/utils/adt/timestamp.c
- Starting at line 2940 of /home/shackle/pggit/postgresql/src/backend/utils/adt/timestamp.c
- if (timestamp2tm(timestamp, NULL, tm, &fsec, NULL, NULL) != 0)
- ereport(ERROR,
- (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
- errmsg("timestamp out of range")));
- tm->tm_mon += span->month;
- if (tm->tm_mon > MONTHS_PER_YEAR)
- {
- tm->tm_year += (tm->tm_mon - 1) / MONTHS_PER_YEAR;
- tm->tm_mon = ((tm->tm_mon - 1) % MONTHS_PER_YEAR) + 1;
- }
- else if (tm->tm_mon < 1)
- {
- tm->tm_year += tm->tm_mon / MONTHS_PER_YEAR - 1;
- tm->tm_mon = tm->tm_mon % MONTHS_PER_YEAR + MONTHS_PER_YEAR;
- }
- /* adjust for end of month boundary problems... */
- if (tm->tm_mday > day_tab[isleap(tm->tm_year)][tm->tm_mon - 1])
- tm->tm_mday = (day_tab[isleap(tm->tm_year)][tm->tm_mon - 1]);
- =====================================================================
- Found a 54 line (161 tokens) duplication in the following files:
- Starting at line 4605 of /home/shackle/pggit/postgresql/src/backend/commands/copy.c
- Starting at line 4665 of /home/shackle/pggit/postgresql/src/backend/commands/copy.c
- {
- start = ptr;
- while ((c = *ptr) != '\0')
- {
- if ((unsigned char) c < (unsigned char) 0x20)
- {
- /*
- * \r and \n must be escaped, the others are traditional. We
- * prefer to dump these using the C-like notation, rather than
- * a backslash and the literal character, because it makes the
- * dump file a bit more proof against Microsoftish data
- * mangling.
- */
- switch (c)
- {
- case '\b':
- c = 'b';
- break;
- case '\f':
- c = 'f';
- break;
- case '\n':
- c = 'n';
- break;
- case '\r':
- c = 'r';
- break;
- case '\t':
- c = 't';
- break;
- case '\v':
- c = 'v';
- break;
- default:
- /* If it's the delimiter, must backslash it */
- if (c == delimc)
- break;
- /* All ASCII control chars are length 1 */
- ptr++;
- continue; /* fall to end of loop */
- }
- /* if we get here, we need to convert the control char */
- DUMPSOFAR();
- CopySendChar(cstate, '\\');
- CopySendChar(cstate, c);
- start = ++ptr; /* do not include char in next run */
- }
- else if (c == '\\' || c == delimc)
- {
- DUMPSOFAR();
- CopySendChar(cstate, '\\');
- start = ptr++; /* we include char in next run */
- }
- else if (IS_HIGHBIT_SET(c))
- =====================================================================
- Found a 50 line (160 tokens) duplication in the following files:
- Starting at line 4315 of /home/shackle/pggit/postgresql/src/backend/optimizer/path/indxpath.c
- Starting at line 6489 of /home/shackle/pggit/postgresql/src/backend/utils/adt/selfuncs.c
- if (datatype == NAMEOID)
- return DirectFunctionCall1(namein, CStringGetDatum(str));
- else if (datatype == BYTEAOID)
- return DirectFunctionCall1(byteain, CStringGetDatum(str));
- else
- return CStringGetTextDatum(str);
- }
- /*
- * Generate a Const node of the appropriate type from a C string.
- */
- static Const *
- string_to_const(const char *str, Oid datatype)
- {
- Datum conval = string_to_datum(str, datatype);
- Oid collation;
- int constlen;
- /*
- * We only need to support a few datatypes here, so hard-wire properties
- * instead of incurring the expense of catalog lookups.
- */
- switch (datatype)
- {
- case TEXTOID:
- case VARCHAROID:
- case BPCHAROID:
- collation = DEFAULT_COLLATION_OID;
- constlen = -1;
- break;
- case NAMEOID:
- collation = InvalidOid;
- constlen = NAMEDATALEN;
- break;
- case BYTEAOID:
- collation = InvalidOid;
- constlen = -1;
- break;
- default:
- elog(ERROR, "unexpected datatype in string_to_const: %u",
- datatype);
- return NULL;
- }
- return makeConst(datatype, -1, collation, constlen,
- conval, false, false);
- }
- =====================================================================
- Found a 36 line (159 tokens) duplication in the following files:
- Starting at line 908 of /home/shackle/pggit/postgresql/src/bin/pg_ctl/pg_ctl.c
- Starting at line 997 of /home/shackle/pggit/postgresql/src/bin/pg_ctl/pg_ctl.c
- if (shutdown_mode == SMART_MODE &&
- stat(backup_file, &statbuf) == 0 &&
- get_control_dbstate() != DB_IN_ARCHIVE_RECOVERY)
- {
- print_msg(_("WARNING: online backup mode is active\n"
- "Shutdown will not complete until pg_stop_backup() is called.\n\n"));
- }
- print_msg(_("waiting for server to shut down..."));
- for (cnt = 0; cnt < wait_seconds * WAITS_PER_SEC; cnt++)
- {
- if ((pid = get_pgpid(false)) != 0)
- {
- if (cnt % WAITS_PER_SEC == 0)
- print_msg(".");
- pg_usleep(USEC_PER_SEC / WAITS_PER_SEC);
- }
- else
- break;
- }
- if (pid != 0) /* pid file still exists */
- {
- print_msg(_(" failed\n"));
- write_stderr(_("%s: server does not shut down\n"), progname);
- if (shutdown_mode == SMART_MODE)
- write_stderr(_("HINT: The \"-m fast\" option immediately disconnects sessions rather than\n"
- "waiting for session-initiated disconnection.\n"));
- exit(1);
- }
- print_msg(_(" done\n"));
- print_msg(_("server stopped\n"));
- }
- =====================================================================
- Found a 31 line (159 tokens) duplication in the following files:
- Starting at line 6568 of /home/shackle/pggit/postgresql/src/pl/plpgsql/src/pl_exec.c
- Starting at line 6608 of /home/shackle/pggit/postgresql/src/pl/plpgsql/src/pl_exec.c
- plpgsql_param_eval_generic(ExprState *state, ExprEvalStep *op,
- ExprContext *econtext)
- {
- ParamListInfo params;
- PLpgSQL_execstate *estate;
- int dno = op->d.cparam.paramid - 1;
- PLpgSQL_datum *datum;
- Oid datumtype;
- int32 datumtypmod;
- /* fetch back the hook data */
- params = econtext->ecxt_param_list_info;
- estate = (PLpgSQL_execstate *) params->paramFetchArg;
- Assert(dno >= 0 && dno < estate->ndatums);
- /* now we can access the target datum */
- datum = estate->datums[dno];
- /* fetch datum's value */
- exec_eval_datum(estate, datum,
- &datumtype, &datumtypmod,
- op->resvalue, op->resnull);
- /* safety check -- needed for, eg, record fields */
- if (unlikely(datumtype != op->d.cparam.paramtype))
- ereport(ERROR,
- (errcode(ERRCODE_DATATYPE_MISMATCH),
- errmsg("type of parameter %d (%s) does not match that when preparing the plan (%s)",
- op->d.cparam.paramid,
- format_type_be(datumtype),
- format_type_be(op->d.cparam.paramtype))));
- =====================================================================
- Found a 36 line (159 tokens) duplication in the following files:
- Starting at line 1534 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-secure-openssl.c
- Starting at line 723 of /home/shackle/pggit/postgresql/src/backend/libpq/be-secure-openssl.c
- my_bio_methods = BIO_meth_new(my_bio_index, "libpq socket");
- if (!my_bio_methods)
- return NULL;
- /*
- * As of this writing, these functions never fail. But check anyway,
- * like OpenSSL's own examples do.
- */
- if (!BIO_meth_set_write(my_bio_methods, my_sock_write) ||
- !BIO_meth_set_read(my_bio_methods, my_sock_read) ||
- !BIO_meth_set_gets(my_bio_methods, BIO_meth_get_gets(biom)) ||
- !BIO_meth_set_puts(my_bio_methods, BIO_meth_get_puts(biom)) ||
- !BIO_meth_set_ctrl(my_bio_methods, BIO_meth_get_ctrl(biom)) ||
- !BIO_meth_set_create(my_bio_methods, BIO_meth_get_create(biom)) ||
- !BIO_meth_set_destroy(my_bio_methods, BIO_meth_get_destroy(biom)) ||
- !BIO_meth_set_callback_ctrl(my_bio_methods, BIO_meth_get_callback_ctrl(biom)))
- {
- BIO_meth_free(my_bio_methods);
- my_bio_methods = NULL;
- return NULL;
- }
- #else
- my_bio_methods = malloc(sizeof(BIO_METHOD));
- if (!my_bio_methods)
- return NULL;
- memcpy(my_bio_methods, biom, sizeof(BIO_METHOD));
- my_bio_methods->bread = my_sock_read;
- my_bio_methods->bwrite = my_sock_write;
- #endif
- }
- return my_bio_methods;
- }
- /* This should exactly match OpenSSL's SSL_set_fd except for using my BIO */
- static int
- my_SSL_set_fd(PGconn *conn, int fd)
- =====================================================================
- Found a 66 line (159 tokens) duplication in the following files:
- Starting at line 947 of /home/shackle/pggit/postgresql/src/backend/utils/adt/float.c
- Starting at line 1016 of /home/shackle/pggit/postgresql/src/backend/utils/adt/float.c
- float8 base = PG_GETARG_FLOAT8(1);
- float8 offset = PG_GETARG_FLOAT8(2);
- bool sub = PG_GETARG_BOOL(3);
- bool less = PG_GETARG_BOOL(4);
- float8 sum;
- /*
- * Reject negative or NaN offset. Negative is per spec, and NaN is
- * because appropriate semantics for that seem non-obvious.
- */
- if (isnan(offset) || offset < 0)
- ereport(ERROR,
- (errcode(ERRCODE_INVALID_PRECEDING_OR_FOLLOWING_SIZE),
- errmsg("invalid preceding or following size in window function")));
- /*
- * Deal with cases where val and/or base is NaN, following the rule that
- * NaN sorts after non-NaN (cf float8_cmp_internal). The offset cannot
- * affect the conclusion.
- */
- if (isnan(val))
- {
- if (isnan(base))
- PG_RETURN_BOOL(true); /* NAN = NAN */
- else
- PG_RETURN_BOOL(!less); /* NAN > non-NAN */
- }
- else if (isnan(base))
- {
- PG_RETURN_BOOL(less); /* non-NAN < NAN */
- }
- /*
- * Deal with infinite offset (necessarily +inf, at this point). We must
- * special-case this because if base happens to be -inf, their sum would
- * be NaN, which is an overflow-ish condition we should avoid.
- */
- if (isinf(offset))
- {
- PG_RETURN_BOOL(sub ? !less : less);
- }
- /*
- * Otherwise it should be safe to compute base +/- offset. We trust the
- * FPU to cope if base is +/-inf or the true sum would overflow, and
- * produce a suitably signed infinity, which will compare properly against
- * val whether or not that's infinity.
- */
- if (sub)
- sum = base - offset;
- else
- sum = base + offset;
- if (less)
- PG_RETURN_BOOL(val <= sum);
- else
- PG_RETURN_BOOL(val >= sum);
- }
- /*
- * in_range support function for float4.
- *
- * We would need a float4_float8 variant in any case, so we supply that and
- * let implicit coercion take care of the float4_float4 case.
- */
- Datum
- =====================================================================
- Found a 49 line (158 tokens) duplication in the following files:
- Starting at line 1788 of /home/shackle/pggit/postgresql/contrib/postgres_fdw/postgres_fdw.c
- Starting at line 1864 of /home/shackle/pggit/postgresql/contrib/postgres_fdw/postgres_fdw.c
- Starting at line 1940 of /home/shackle/pggit/postgresql/contrib/postgres_fdw/postgres_fdw.c
- p_values = convert_prep_stmt_params(fmstate, NULL, slot);
- /*
- * Execute the prepared statement.
- */
- if (!PQsendQueryPrepared(fmstate->conn,
- fmstate->p_name,
- fmstate->p_nums,
- p_values,
- NULL,
- NULL,
- 0))
- pgfdw_report_error(ERROR, NULL, fmstate->conn, false, fmstate->query);
- /*
- * Get the result, and check for success.
- *
- * We don't use a PG_TRY block here, so be careful not to throw error
- * without releasing the PGresult.
- */
- res = pgfdw_get_result(fmstate->conn, fmstate->query);
- if (PQresultStatus(res) !=
- (fmstate->has_returning ? PGRES_TUPLES_OK : PGRES_COMMAND_OK))
- pgfdw_report_error(ERROR, res, fmstate->conn, true, fmstate->query);
- /* Check number of rows affected, and fetch RETURNING tuple if any */
- if (fmstate->has_returning)
- {
- n_rows = PQntuples(res);
- if (n_rows > 0)
- store_returning_result(fmstate, slot, res);
- }
- else
- n_rows = atoi(PQcmdTuples(res));
- /* And clean up */
- PQclear(res);
- MemoryContextReset(fmstate->temp_cxt);
- /* Return NULL if nothing was inserted on the remote end */
- return (n_rows > 0) ? slot : NULL;
- }
- /*
- * postgresExecForeignUpdate
- * Update one row in a foreign table
- */
- static TupleTableSlot *
- =====================================================================
- Found a 28 line (158 tokens) duplication in the following files:
- Starting at line 204 of /home/shackle/pggit/postgresql/src/backend/commands/dbcommands.c
- Starting at line 1423 of /home/shackle/pggit/postgresql/src/backend/commands/dbcommands.c
- else if (strcmp(defel->defname, "is_template") == 0)
- {
- if (distemplate)
- ereport(ERROR,
- (errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options"),
- parser_errposition(pstate, defel->location)));
- distemplate = defel;
- }
- else if (strcmp(defel->defname, "allow_connections") == 0)
- {
- if (dallowconnections)
- ereport(ERROR,
- (errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options"),
- parser_errposition(pstate, defel->location)));
- dallowconnections = defel;
- }
- else if (strcmp(defel->defname, "connection_limit") == 0)
- {
- if (dconnlimit)
- ereport(ERROR,
- (errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options"),
- parser_errposition(pstate, defel->location)));
- dconnlimit = defel;
- }
- else if (strcmp(defel->defname, "location") == 0)
- =====================================================================
- Found a 22 line (157 tokens) duplication in the following files:
- Starting at line 1275 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
- Starting at line 1588 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
- InitFunctionCallInfoData(fcinfo, flinfo, 7, collation, NULL, NULL);
- fcinfo.arg[0] = arg1;
- fcinfo.arg[1] = arg2;
- fcinfo.arg[2] = arg3;
- fcinfo.arg[3] = arg4;
- fcinfo.arg[4] = arg5;
- fcinfo.arg[5] = arg6;
- fcinfo.arg[6] = arg7;
- fcinfo.argnull[0] = false;
- fcinfo.argnull[1] = false;
- fcinfo.argnull[2] = false;
- fcinfo.argnull[3] = false;
- fcinfo.argnull[4] = false;
- fcinfo.argnull[5] = false;
- fcinfo.argnull[6] = false;
- result = FunctionCallInvoke(&fcinfo);
- /* Check for null result, since caller is clearly not expecting one */
- if (fcinfo.isnull)
- elog(ERROR, "function %u returned NULL", fcinfo.flinfo->fn_oid);
- =====================================================================
- Found a 13 line (157 tokens) duplication in the following files:
- Starting at line 1737 of /home/shackle/pggit/postgresql/src/backend/utils/mb/wchar.c
- Starting at line 1753 of /home/shackle/pggit/postgresql/src/backend/utils/mb/wchar.c
- {pg_mule2wchar_with_len, pg_wchar2mule_with_len, pg_mule_mblen, pg_mule_dsplen, pg_mule_verifier, 4}, /* PG_MULE_INTERNAL */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN1 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN2 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN3 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN4 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN5 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN6 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN7 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN8 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN9 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN10 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_WIN1256 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_WIN1258 */
- =====================================================================
- Found a 35 line (156 tokens) duplication in the following files:
- Starting at line 456 of /home/shackle/pggit/postgresql/contrib/hstore/hstore_gist.c
- Starting at line 448 of /home/shackle/pggit/postgresql/contrib/intarray/_intbig_gist.c
- if (size_alpha < size_beta + WISH_F(v->spl_nleft, v->spl_nright, 0.0001))
- {
- if (ISALLTRUE(datum_l) || ISALLTRUE(_j))
- {
- if (!ISALLTRUE(datum_l))
- MemSet((void *) union_l, 0xff, sizeof(BITVEC));
- }
- else
- {
- ptr = GETSIGN(_j);
- LOOPBYTE
- union_l[i] |= ptr[i];
- }
- *left++ = j;
- v->spl_nleft++;
- }
- else
- {
- if (ISALLTRUE(datum_r) || ISALLTRUE(_j))
- {
- if (!ISALLTRUE(datum_r))
- MemSet((void *) union_r, 0xff, sizeof(BITVEC));
- }
- else
- {
- ptr = GETSIGN(_j);
- LOOPBYTE
- union_r[i] |= ptr[i];
- }
- *right++ = j;
- v->spl_nright++;
- }
- }
- *right = *left = FirstOffsetNumber;
- =====================================================================
- Found a 20 line (156 tokens) duplication in the following files:
- Starting at line 989 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
- Starting at line 1309 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
- Starting at line 1625 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
- InitFunctionCallInfoData(fcinfo, NULL, 8, collation, NULL, NULL);
- fcinfo.arg[0] = arg1;
- fcinfo.arg[1] = arg2;
- fcinfo.arg[2] = arg3;
- fcinfo.arg[3] = arg4;
- fcinfo.arg[4] = arg5;
- fcinfo.arg[5] = arg6;
- fcinfo.arg[6] = arg7;
- fcinfo.arg[7] = arg8;
- fcinfo.argnull[0] = false;
- fcinfo.argnull[1] = false;
- fcinfo.argnull[2] = false;
- fcinfo.argnull[3] = false;
- fcinfo.argnull[4] = false;
- fcinfo.argnull[5] = false;
- fcinfo.argnull[6] = false;
- fcinfo.argnull[7] = false;
- result = (*func) (&fcinfo);
- =====================================================================
- Found a 34 line (156 tokens) duplication in the following files:
- Starting at line 5801 of /home/shackle/pggit/postgresql/src/backend/utils/adt/formatting.c
- Starting at line 5904 of /home/shackle/pggit/postgresql/src/backend/utils/adt/formatting.c
- Num.post = FLT_DIG - numstr_pre_len;
- orgnum = psprintf("%.*f", Num.post, val);
- if (*orgnum == '-')
- { /* < 0 */
- sign = '-';
- numstr = orgnum + 1;
- }
- else
- {
- sign = '+';
- numstr = orgnum;
- }
- if ((p = strchr(numstr, '.')))
- numstr_pre_len = p - numstr;
- else
- numstr_pre_len = strlen(numstr);
- /* needs padding? */
- if (numstr_pre_len < Num.pre)
- out_pre_spaces = Num.pre - numstr_pre_len;
- /* overflowed prefix digit format? */
- else if (numstr_pre_len > Num.pre)
- {
- numstr = (char *) palloc(Num.pre + Num.post + 2);
- fill_str(numstr, '#', Num.pre + Num.post + 1);
- *(numstr + Num.pre) = '.';
- }
- }
- NUM_TOCHAR_finish;
- PG_RETURN_TEXT_P(result);
- }
- =====================================================================
- Found a 31 line (156 tokens) duplication in the following files:
- Starting at line 547 of /home/shackle/pggit/postgresql/src/backend/utils/adt/pgstatfuncs.c
- Starting at line 1100 of /home/shackle/pggit/postgresql/src/backend/replication/logical/launcher.c
- int pid = PG_ARGISNULL(0) ? -1 : PG_GETARG_INT32(0);
- ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo;
- TupleDesc tupdesc;
- Tuplestorestate *tupstore;
- MemoryContext per_query_ctx;
- MemoryContext oldcontext;
- /* check to see if caller supports us returning a tuplestore */
- if (rsinfo == NULL || !IsA(rsinfo, ReturnSetInfo))
- ereport(ERROR,
- (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("set-valued function called in context that cannot accept a set")));
- if (!(rsinfo->allowedModes & SFRM_Materialize))
- ereport(ERROR,
- (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("materialize mode required, but it is not " \
- "allowed in this context")));
- /* Build a tuple descriptor for our result type */
- if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
- elog(ERROR, "return type must be a row type");
- per_query_ctx = rsinfo->econtext->ecxt_per_query_memory;
- oldcontext = MemoryContextSwitchTo(per_query_ctx);
- tupstore = tuplestore_begin_heap(true, false, work_mem);
- rsinfo->returnMode = SFRM_Materialize;
- rsinfo->setResult = tupstore;
- rsinfo->setDesc = tupdesc;
- MemoryContextSwitchTo(oldcontext);
- =====================================================================
- Found a 33 line (155 tokens) duplication in the following files:
- Starting at line 951 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/ecpglib/execute.c
- Starting at line 998 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/ecpglib/execute.c
- str = quote_postgres(PGTYPESdate_to_asc(((date *) (var->value))[element]), quote, lineno);
- if (!str)
- {
- ecpg_free(mallocedval);
- return false;
- }
- slen = strlen(str);
- if (!(newcopy = ecpg_realloc(mallocedval, strlen(mallocedval) + slen + 2, lineno)))
- {
- ecpg_free(mallocedval);
- ecpg_free(str);
- return false;
- }
- mallocedval = newcopy;
- /* also copy trailing '\0' */
- memcpy(mallocedval + strlen(mallocedval), str, slen + 1);
- if (var->arrsize > 1)
- strcpy(mallocedval + strlen(mallocedval), ",");
- ecpg_free(str);
- }
- if (var->arrsize > 1)
- strcpy(mallocedval + strlen(mallocedval) - 1, "}");
- *tobeinserted_p = mallocedval;
- }
- break;
- case ECPGt_timestamp:
- =====================================================================
- Found a 46 line (155 tokens) duplication in the following files:
- Starting at line 113 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/interval.c
- Starting at line 3508 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
- int *dtype, struct /* pg_ */ tm *tm, fsec_t *fsec)
- {
- bool datepart = true;
- bool havefield = false;
- *dtype = DTK_DELTA;
- ClearPgTm(tm, fsec);
- if (strlen(str) < 2 || str[0] != 'P')
- return DTERR_BAD_FORMAT;
- str++;
- while (*str)
- {
- char *fieldstart;
- int val;
- double fval;
- char unit;
- int dterr;
- if (*str == 'T') /* T indicates the beginning of the time part */
- {
- datepart = false;
- havefield = false;
- str++;
- continue;
- }
- fieldstart = str;
- dterr = ParseISO8601Number(str, &str, &val, &fval);
- if (dterr)
- return dterr;
- /*
- * Note: we could step off the end of the string here. Code below
- * *must* exit the loop if unit == '\0'.
- */
- unit = *str++;
- if (datepart)
- {
- switch (unit) /* before T: Y M W D */
- {
- case 'Y':
- tm->tm_year += val;
- tm->tm_mon += (fval * 12);
- =====================================================================
- Found a 32 line (155 tokens) duplication in the following files:
- Starting at line 5739 of /home/shackle/pggit/postgresql/src/backend/utils/adt/formatting.c
- Starting at line 5843 of /home/shackle/pggit/postgresql/src/backend/utils/adt/formatting.c
- float4 value = PG_GETARG_FLOAT4(0);
- text *fmt = PG_GETARG_TEXT_PP(1);
- NUMDesc Num;
- FormatNode *format;
- text *result;
- bool shouldFree;
- int out_pre_spaces = 0,
- sign = 0;
- char *numstr,
- *orgnum,
- *p;
- NUM_TOCHAR_prepare;
- if (IS_ROMAN(&Num))
- numstr = orgnum = int_to_roman((int) rint(value));
- else if (IS_EEEE(&Num))
- {
- if (isnan(value) || isinf(value))
- {
- /*
- * Allow 6 characters for the leading sign, the decimal point,
- * "e", the exponent's sign and two exponent digits.
- */
- numstr = (char *) palloc(Num.pre + Num.post + 7);
- fill_str(numstr, '#', Num.pre + Num.post + 6);
- *numstr = ' ';
- *(numstr + Num.pre + 1) = '.';
- }
- else
- {
- numstr = orgnum = psprintf("%+.*e", Num.post, value);
- =====================================================================
- Found a 45 line (154 tokens) duplication in the following files:
- Starting at line 2172 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/dt_common.c
- Starting at line 1225 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
- tm->tm_sec = 0;
- break;
- case DTK_ZULU:
- tmask = (DTK_TIME_M | DTK_M(TZ));
- *dtype = DTK_DATE;
- tm->tm_hour = 0;
- tm->tm_min = 0;
- tm->tm_sec = 0;
- if (tzp != NULL)
- *tzp = 0;
- break;
- default:
- *dtype = val;
- }
- break;
- case MONTH:
- /*
- * already have a (numeric) month? then see if we can
- * substitute...
- */
- if ((fmask & DTK_M(MONTH)) && !haveTextMonth &&
- !(fmask & DTK_M(DAY)) && tm->tm_mon >= 1 && tm->tm_mon <= 31)
- {
- tm->tm_mday = tm->tm_mon;
- tmask = DTK_M(DAY);
- }
- haveTextMonth = true;
- tm->tm_mon = val;
- break;
- case DTZMOD:
- /*
- * daylight savings time modifier (solves "MET DST"
- * syntax)
- */
- tmask |= DTK_M(DTZ);
- tm->tm_isdst = 1;
- if (tzp == NULL)
- return -1;
- =====================================================================
- Found a 16 line (154 tokens) duplication in the following files:
- Starting at line 216 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 356 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 524 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
- ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
- #line 74 "cursor.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 74 "cursor.pgc"
- printf("%d %s\n", id, t);
- strcpy(msg, "fetch 1 from");
- { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch 1 from $0",
- ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
- =====================================================================
- Found a 16 line (154 tokens) duplication in the following files:
- Starting at line 292 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 436 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 600 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
- ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
- #line 95 "cursor.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 95 "cursor.pgc"
- printf("%d %s\n", id, t);
- strcpy(msg, "close");
- { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "close $0",
- ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
- =====================================================================
- Found a 16 line (154 tokens) duplication in the following files:
- Starting at line 389 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 557 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
- ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
- #line 124 "cursor.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 124 "cursor.pgc"
- printf("%d %s\n", id, t);
- strcpy(msg, "move");
- { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "move absolute 0 $0",
- ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
- =====================================================================
- Found a 19 line (154 tokens) duplication in the following files:
- Starting at line 420 of /home/shackle/pggit/postgresql/src/backend/nodes/outfuncs.c
- Starting at line 511 of /home/shackle/pggit/postgresql/src/backend/nodes/outfuncs.c
- Starting at line 891 of /home/shackle/pggit/postgresql/src/backend/nodes/outfuncs.c
- WRITE_NODE_FIELD(mergeplans);
- WRITE_INT_FIELD(numCols);
- appendStringInfoString(str, " :sortColIdx");
- for (i = 0; i < node->numCols; i++)
- appendStringInfo(str, " %d", node->sortColIdx[i]);
- appendStringInfoString(str, " :sortOperators");
- for (i = 0; i < node->numCols; i++)
- appendStringInfo(str, " %u", node->sortOperators[i]);
- appendStringInfoString(str, " :collations");
- for (i = 0; i < node->numCols; i++)
- appendStringInfo(str, " %u", node->collations[i]);
- appendStringInfoString(str, " :nullsFirst");
- for (i = 0; i < node->numCols; i++)
- appendStringInfo(str, " %s", booltostr(node->nullsFirst[i]));
- =====================================================================
- Found a 24 line (154 tokens) duplication in the following files:
- Starting at line 389 of /home/shackle/pggit/postgresql/src/backend/tsearch/wparser.c
- Starting at line 465 of /home/shackle/pggit/postgresql/src/backend/tsearch/wparser.c
- Jsonb *out;
- JsonTransformStringValuesAction action = (JsonTransformStringValuesAction) headline_json_value;
- HeadlineParsedText prs;
- HeadlineJsonState *state = palloc0(sizeof(HeadlineJsonState));
- memset(&prs, 0, sizeof(HeadlineParsedText));
- prs.lenwords = 32;
- prs.words = (HeadlineWordEntry *) palloc(sizeof(HeadlineWordEntry) * prs.lenwords);
- state->prs = &prs;
- state->cfg = lookup_ts_config_cache(tsconfig);
- state->prsobj = lookup_ts_parser_cache(state->cfg->prsId);
- state->query = query;
- if (opt)
- state->prsoptions = deserialize_deflist(PointerGetDatum(opt));
- else
- state->prsoptions = NIL;
- if (!OidIsValid(state->prsobj->headlineOid))
- ereport(ERROR,
- (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("text search parser does not support headline creation")));
- out = transform_jsonb_string_values(jb, state, action);
- =====================================================================
- Found a 47 line (153 tokens) duplication in the following files:
- Starting at line 130 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/compat_informix-describe.c
- Starting at line 128 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-describe.c
- { ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into descr_t1 ( id , t ) values ( default , 'd' )", ECPGt_EOIT, ECPGt_EORT);
- #line 39 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 39 "describe.pgc"
- strcpy(msg, "commit");
- { ECPGtrans(__LINE__, NULL, "commit");
- #line 42 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 42 "describe.pgc"
- /*
- * Test DESCRIBE with a query producing tuples.
- * DESCRIPTOR and SQL DESCRIPTOR are NOT the same in
- * Informix-compat mode.
- */
- strcpy(msg, "allocate");
- ECPGallocate_desc(__LINE__, "desc1");
- #line 51 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);
- #line 51 "describe.pgc"
- ECPGallocate_desc(__LINE__, "desc2");
- #line 52 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);
- #line 52 "describe.pgc"
- strcpy(msg, "prepare");
- { ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1);
- #line 55 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 55 "describe.pgc"
- sqlda1 = sqlda2 = sqlda3 = NULL;
- strcpy(msg, "describe");
- { ECPGdescribe(__LINE__, 1, 0, NULL, "st_id1",
- =====================================================================
- Found a 27 line (152 tokens) duplication in the following files:
- Starting at line 489 of /home/shackle/pggit/postgresql/contrib/ltree/ltxtquery_io.c
- Starting at line 614 of /home/shackle/pggit/postgresql/contrib/intarray/_int_bool.c
- nrm.op = in->op;
- nrm.buflen = 16;
- nrm.cur = nrm.buf = (char *) palloc(sizeof(char) * nrm.buflen);
- /* get right operand */
- infix(&nrm, false);
- /* get & print left operand */
- in->curpol = nrm.curpol;
- infix(in, false);
- /* print operator & right operand */
- RESIZEBUF(in, 3 + (nrm.cur - nrm.buf));
- sprintf(in->cur, " %c %s", op, nrm.buf);
- in->cur = strchr(in->cur, '\0');
- pfree(nrm.buf);
- if (op == (int32) '|' && !first)
- {
- RESIZEBUF(in, 2);
- sprintf(in->cur, " )");
- in->cur = strchr(in->cur, '\0');
- }
- }
- }
- Datum
- =====================================================================
- Found a 37 line (152 tokens) duplication in the following files:
- Starting at line 580 of /home/shackle/pggit/postgresql/contrib/pg_trgm/trgm_gist.c
- Starting at line 449 of /home/shackle/pggit/postgresql/src/backend/utils/adt/tsgistidx.c
- TRGM *b = (TRGM *) PG_GETARG_POINTER(1);
- bool *result = (bool *) PG_GETARG_POINTER(2);
- if (ISSIGNKEY(a))
- { /* then b also ISSIGNKEY */
- if (ISALLTRUE(a) && ISALLTRUE(b))
- *result = true;
- else if (ISALLTRUE(a))
- *result = false;
- else if (ISALLTRUE(b))
- *result = false;
- else
- {
- int32 i;
- BITVECP sa = GETSIGN(a),
- sb = GETSIGN(b);
- *result = true;
- LOOPBYTE
- {
- if (sa[i] != sb[i])
- {
- *result = false;
- break;
- }
- }
- }
- }
- else
- { /* a and b ISARRKEY */
- int32 lena = ARRNELEM(a),
- lenb = ARRNELEM(b);
- if (lena != lenb)
- *result = false;
- else
- {
- =====================================================================
- Found a 36 line (151 tokens) duplication in the following files:
- Starting at line 2798 of /home/shackle/pggit/postgresql/src/pl/plpgsql/src/pl_exec.c
- Starting at line 4563 of /home/shackle/pggit/postgresql/src/pl/plpgsql/src/pl_exec.c
- if (stmt->argquery != NULL)
- {
- /* ----------
- * OPEN CURSOR with args. We fake a SELECT ... INTO ...
- * statement to evaluate the args and put 'em into the
- * internal row.
- * ----------
- */
- PLpgSQL_stmt_execsql set_args;
- if (curvar->cursor_explicit_argrow < 0)
- ereport(ERROR,
- (errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("arguments given for cursor without arguments")));
- memset(&set_args, 0, sizeof(set_args));
- set_args.cmd_type = PLPGSQL_STMT_EXECSQL;
- set_args.lineno = stmt->lineno;
- set_args.sqlstmt = stmt->argquery;
- set_args.into = true;
- /* XXX historically this has not been STRICT */
- set_args.target = (PLpgSQL_variable *)
- (estate->datums[curvar->cursor_explicit_argrow]);
- if (exec_stmt_execsql(estate, &set_args) != PLPGSQL_RC_OK)
- elog(ERROR, "open cursor failed during argument processing");
- }
- else
- {
- if (curvar->cursor_explicit_argrow >= 0)
- ereport(ERROR,
- (errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("arguments required for cursor")));
- }
- query = curvar->cursor_explicit_expr;
- =====================================================================
- Found a 38 line (151 tokens) duplication in the following files:
- Starting at line 244 of /home/shackle/pggit/postgresql/src/test/examples/testlo64.c
- Starting at line 220 of /home/shackle/pggit/postgresql/src/test/examples/testlo.c
- out_filename2 = argv[4];
- /*
- * set up the connection
- */
- conn = PQsetdb(NULL, NULL, NULL, NULL, database);
- /* check to see that the backend connection was successfully made */
- if (PQstatus(conn) != CONNECTION_OK)
- {
- fprintf(stderr, "Connection to database failed: %s",
- PQerrorMessage(conn));
- exit_nicely(conn);
- }
- /* Set always-secure search path, so malicious users can't take control. */
- res = PQexec(conn,
- "SELECT pg_catalog.set_config('search_path', '', false)");
- if (PQresultStatus(res) != PGRES_TUPLES_OK)
- {
- fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
- PQclear(res);
- exit_nicely(conn);
- }
- PQclear(res);
- res = PQexec(conn, "begin");
- PQclear(res);
- printf("importing file \"%s\" ...\n", in_filename);
- /* lobjOid = importFile(conn, in_filename); */
- lobjOid = lo_import(conn, in_filename);
- if (lobjOid == 0)
- fprintf(stderr, "%s\n", PQerrorMessage(conn));
- else
- {
- printf("\tas large object %u.\n", lobjOid);
- printf("picking out bytes 4294967000-4294968000 of the large object\n");
- =====================================================================
- Found a 33 line (151 tokens) duplication in the following files:
- Starting at line 942 of /home/shackle/pggit/postgresql/src/backend/utils/sort/tuplesort.c
- Starting at line 1020 of /home/shackle/pggit/postgresql/src/backend/utils/sort/tuplesort.c
- state->sortKeys = (SortSupport) palloc0(state->nKeys *
- sizeof(SortSupportData));
- for (i = 0; i < state->nKeys; i++)
- {
- SortSupport sortKey = state->sortKeys + i;
- ScanKey scanKey = indexScanKey + i;
- int16 strategy;
- sortKey->ssup_cxt = CurrentMemoryContext;
- sortKey->ssup_collation = scanKey->sk_collation;
- sortKey->ssup_nulls_first =
- (scanKey->sk_flags & SK_BT_NULLS_FIRST) != 0;
- sortKey->ssup_attno = scanKey->sk_attno;
- /* Convey if abbreviation optimization is applicable in principle */
- sortKey->abbreviate = (i == 0);
- AssertState(sortKey->ssup_attno != 0);
- strategy = (scanKey->sk_flags & SK_BT_DESC) != 0 ?
- BTGreaterStrategyNumber : BTLessStrategyNumber;
- PrepareSortSupportFromIndexRel(indexRel, strategy, sortKey);
- }
- _bt_freeskey(indexScanKey);
- MemoryContextSwitchTo(oldcontext);
- return state;
- }
- Tuplesortstate *
- =====================================================================
- Found a 25 line (151 tokens) duplication in the following files:
- Starting at line 218 of /home/shackle/pggit/postgresql/src/backend/access/rmgrdesc/xactdesc.c
- Starting at line 269 of /home/shackle/pggit/postgresql/src/backend/access/rmgrdesc/xactdesc.c
- ParseCommitRecord(info, xlrec, &parsed);
- /* If this is a prepared xact, show the xid of the original xact */
- if (TransactionIdIsValid(parsed.twophase_xid))
- appendStringInfo(buf, "%u: ", parsed.twophase_xid);
- appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time));
- if (parsed.nrels > 0)
- {
- appendStringInfoString(buf, "; rels:");
- for (i = 0; i < parsed.nrels; i++)
- {
- char *path = relpathperm(parsed.xnodes[i], MAIN_FORKNUM);
- appendStringInfo(buf, " %s", path);
- pfree(path);
- }
- }
- if (parsed.nsubxacts > 0)
- {
- appendStringInfoString(buf, "; subxacts:");
- for (i = 0; i < parsed.nsubxacts; i++)
- appendStringInfo(buf, " %u", parsed.subxacts[i]);
- }
- =====================================================================
- Found a 38 line (150 tokens) duplication in the following files:
- Starting at line 2874 of /home/shackle/pggit/postgresql/src/backend/catalog/objectaddress.c
- Starting at line 4428 of /home/shackle/pggit/postgresql/src/backend/catalog/objectaddress.c
- NameStr(conv->conname)));
- ReleaseSysCache(conTup);
- break;
- }
- case OCLASS_DEFAULT:
- {
- Relation attrdefDesc;
- ScanKeyData skey[1];
- SysScanDesc adscan;
- HeapTuple tup;
- Form_pg_attrdef attrdef;
- ObjectAddress colobject;
- attrdefDesc = heap_open(AttrDefaultRelationId, AccessShareLock);
- ScanKeyInit(&skey[0],
- Anum_pg_attrdef_oid,
- BTEqualStrategyNumber, F_OIDEQ,
- ObjectIdGetDatum(object->objectId));
- adscan = systable_beginscan(attrdefDesc, AttrDefaultOidIndexId,
- true, NULL, 1, skey);
- tup = systable_getnext(adscan);
- if (!HeapTupleIsValid(tup))
- elog(ERROR, "could not find tuple for attrdef %u",
- object->objectId);
- attrdef = (Form_pg_attrdef) GETSTRUCT(tup);
- colobject.classId = RelationRelationId;
- colobject.objectId = attrdef->adrelid;
- colobject.objectSubId = attrdef->adnum;
- /* translator: %s is typically "column %s of table %s" */
- appendStringInfo(&buffer, _("default value for %s"),
- =====================================================================
- Found a 37 line (150 tokens) duplication in the following files:
- Starting at line 2028 of /home/shackle/pggit/postgresql/src/backend/utils/adt/selfuncs.c
- Starting at line 2095 of /home/shackle/pggit/postgresql/src/backend/utils/adt/selfuncs.c
- elmbyval));
- if (is_join_clause)
- s2 = DatumGetFloat8(FunctionCall5Coll(&oprselproc,
- clause->inputcollid,
- PointerGetDatum(root),
- ObjectIdGetDatum(operator),
- PointerGetDatum(args),
- Int16GetDatum(jointype),
- PointerGetDatum(sjinfo)));
- else
- s2 = DatumGetFloat8(FunctionCall4Coll(&oprselproc,
- clause->inputcollid,
- PointerGetDatum(root),
- ObjectIdGetDatum(operator),
- PointerGetDatum(args),
- Int32GetDatum(varRelid)));
- if (useOr)
- {
- s1 = s1 + s2 - s1 * s2;
- if (isEquality)
- s1disjoint += s2;
- }
- else
- {
- s1 = s1 * s2;
- if (isInequality)
- s1disjoint += s2 - 1.0;
- }
- }
- /* accept disjoint-probability estimate if in range */
- if ((useOr ? isEquality : isInequality) &&
- s1disjoint >= 0.0 && s1disjoint <= 1.0)
- s1 = s1disjoint;
- }
- else if (rightop && IsA(rightop, ArrayExpr) &&
- =====================================================================
- Found a 35 line (150 tokens) duplication in the following files:
- Starting at line 380 of /home/shackle/pggit/postgresql/src/backend/utils/adt/arrayfuncs.c
- Starting at line 1384 of /home/shackle/pggit/postgresql/src/backend/utils/adt/arrayfuncs.c
- typdelim,
- typlen, typbyval, typalign,
- dataPtr, nullsPtr,
- &hasnulls, &nbytes);
- if (hasnulls)
- {
- dataoffset = ARR_OVERHEAD_WITHNULLS(ndim, nitems);
- nbytes += dataoffset;
- }
- else
- {
- dataoffset = 0; /* marker for no null bitmap */
- nbytes += ARR_OVERHEAD_NONULLS(ndim);
- }
- retval = (ArrayType *) palloc0(nbytes);
- SET_VARSIZE(retval, nbytes);
- retval->ndim = ndim;
- retval->dataoffset = dataoffset;
- /*
- * This comes from the array's pg_type.typelem (which points to the base
- * data type's pg_type.oid) and stores system oids in user tables. This
- * oid must be preserved by binary upgrades.
- */
- retval->elemtype = element_type;
- memcpy(ARR_DIMS(retval), dim, ndim * sizeof(int));
- memcpy(ARR_LBOUND(retval), lBound, ndim * sizeof(int));
- CopyArrayEls(retval,
- dataPtr, nullsPtr, nitems,
- typlen, typbyval, typalign,
- true);
- pfree(dataPtr);
- pfree(nullsPtr);
- =====================================================================
- Found a 30 line (149 tokens) duplication in the following files:
- Starting at line 2681 of /home/shackle/pggit/postgresql/src/backend/executor/spi.c
- Starting at line 2745 of /home/shackle/pggit/postgresql/src/backend/executor/spi.c
- plancxt = AllocSetContextCreate(parentcxt,
- "SPI Plan",
- ALLOCSET_SMALL_SIZES);
- oldcxt = MemoryContextSwitchTo(plancxt);
- /* Copy the SPI_plan struct and subsidiary data into the new context */
- newplan = (SPIPlanPtr) palloc0(sizeof(_SPI_plan));
- newplan->magic = _SPI_PLAN_MAGIC;
- newplan->plancxt = plancxt;
- newplan->cursor_options = plan->cursor_options;
- newplan->nargs = plan->nargs;
- if (plan->nargs > 0)
- {
- newplan->argtypes = (Oid *) palloc(plan->nargs * sizeof(Oid));
- memcpy(newplan->argtypes, plan->argtypes, plan->nargs * sizeof(Oid));
- }
- else
- newplan->argtypes = NULL;
- newplan->parserSetup = plan->parserSetup;
- newplan->parserSetupArg = plan->parserSetupArg;
- /*
- * Reparent all the CachedPlanSources into the procedure context. In
- * theory this could fail partway through due to the pallocs, but we don't
- * care too much since both the procedure context and the executor context
- * would go away on error.
- */
- foreach(lc, plan->plancache_list)
- {
- CachedPlanSource *plansource = (CachedPlanSource *) lfirst(lc);
- =====================================================================
- Found a 34 line (149 tokens) duplication in the following files:
- Starting at line 531 of /home/shackle/pggit/postgresql/src/backend/libpq/be-secure-openssl.c
- Starting at line 590 of /home/shackle/pggit/postgresql/src/backend/libpq/be-secure-openssl.c
- n = SSL_read(port->ssl, ptr, len);
- err = SSL_get_error(port->ssl, n);
- ecode = (err != SSL_ERROR_NONE || n < 0) ? ERR_get_error() : 0;
- switch (err)
- {
- case SSL_ERROR_NONE:
- /* a-ok */
- break;
- case SSL_ERROR_WANT_READ:
- *waitfor = WL_SOCKET_READABLE;
- errno = EWOULDBLOCK;
- n = -1;
- break;
- case SSL_ERROR_WANT_WRITE:
- *waitfor = WL_SOCKET_WRITEABLE;
- errno = EWOULDBLOCK;
- n = -1;
- break;
- case SSL_ERROR_SYSCALL:
- /* leave it to caller to ereport the value of errno */
- if (n != -1)
- {
- errno = ECONNRESET;
- n = -1;
- }
- break;
- case SSL_ERROR_SSL:
- ereport(COMMERROR,
- (errcode(ERRCODE_PROTOCOL_VIOLATION),
- errmsg("SSL error: %s", SSLerrmessage(ecode))));
- errno = ECONNRESET;
- n = -1;
- break;
- case SSL_ERROR_ZERO_RETURN:
- =====================================================================
- Found a 32 line (149 tokens) duplication in the following files:
- Starting at line 1040 of /home/shackle/pggit/postgresql/src/backend/utils/adt/arrayfuncs.c
- Starting at line 4568 of /home/shackle/pggit/postgresql/src/backend/utils/adt/varlena.c
- ArrayMetaState *my_extra;
- /*
- * We arrange to look up info about element type, including its output
- * conversion proc, only once per series of calls, assuming the element
- * type doesn't change underneath us.
- */
- my_extra = (ArrayMetaState *) fcinfo->flinfo->fn_extra;
- if (my_extra == NULL)
- {
- fcinfo->flinfo->fn_extra = MemoryContextAlloc(fcinfo->flinfo->fn_mcxt,
- sizeof(ArrayMetaState));
- my_extra = (ArrayMetaState *) fcinfo->flinfo->fn_extra;
- my_extra->element_type = ~element_type;
- }
- if (my_extra->element_type != element_type)
- {
- /*
- * Get info about element type, including its output conversion proc
- */
- get_type_io_data(element_type, IOFunc_output,
- &my_extra->typlen, &my_extra->typbyval,
- &my_extra->typalign, &my_extra->typdelim,
- &my_extra->typioparam, &my_extra->typiofunc);
- fmgr_info_cxt(my_extra->typiofunc, &my_extra->proc,
- fcinfo->flinfo->fn_mcxt);
- my_extra->element_type = element_type;
- }
- typlen = my_extra->typlen;
- typbyval = my_extra->typbyval;
- typalign = my_extra->typalign;
- =====================================================================
- Found a 30 line (149 tokens) duplication in the following files:
- Starting at line 523 of /home/shackle/pggit/postgresql/src/backend/commands/opclasscmds.c
- Starting at line 902 of /home/shackle/pggit/postgresql/src/backend/commands/opclasscmds.c
- assignOperTypes(member, amoid, typeoid);
- addFamilyMember(&operators, member, false);
- break;
- case OPCLASS_ITEM_FUNCTION:
- if (item->number <= 0 || item->number > maxProcNumber)
- ereport(ERROR,
- (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
- errmsg("invalid function number %d,"
- " must be between 1 and %d",
- item->number, maxProcNumber)));
- funcOid = LookupFuncWithArgs(OBJECT_FUNCTION, item->name, false);
- #ifdef NOT_USED
- /* XXX this is unnecessary given the superuser check above */
- /* Caller must own function */
- if (!pg_proc_ownercheck(funcOid, GetUserId()))
- aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_FUNCTION,
- get_func_name(funcOid));
- #endif
- /* Save the info */
- member = (OpFamilyMember *) palloc0(sizeof(OpFamilyMember));
- member->object = funcOid;
- member->number = item->number;
- /* allow overriding of the function's actual arg types */
- if (item->class_args)
- processTypesSpec(item->class_args,
- &member->lefttype, &member->righttype);
- assignProcTypes(member, amoid, typeoid);
- =====================================================================
- Found a 27 line (148 tokens) duplication in the following files:
- Starting at line 430 of /home/shackle/pggit/postgresql/contrib/hstore/hstore_gist.c
- Starting at line 422 of /home/shackle/pggit/postgresql/contrib/intarray/_intbig_gist.c
- costvector[j - 1].cost = abs(size_alpha - size_beta);
- }
- qsort((void *) costvector, maxoff, sizeof(SPLITCOST), comparecost);
- union_l = GETSIGN(datum_l);
- union_r = GETSIGN(datum_r);
- for (k = 0; k < maxoff; k++)
- {
- j = costvector[k].pos;
- if (j == seed_1)
- {
- *left++ = j;
- v->spl_nleft++;
- continue;
- }
- else if (j == seed_2)
- {
- *right++ = j;
- v->spl_nright++;
- continue;
- }
- _j = GETENTRY(entryvec, j);
- size_alpha = hemdist(datum_l, _j);
- size_beta = hemdist(datum_r, _j);
- if (size_alpha < size_beta + WISH_F(v->spl_nleft, v->spl_nright, 0.0001))
- =====================================================================
- Found a 16 line (148 tokens) duplication in the following files:
- Starting at line 203 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-array.c
- Starting at line 243 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-array.c
- { 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 )",
- ECPGt_timestamp,&(ts),(long)1,(long)10,sizeof(timestamp),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_numeric,&(n),(long)1,(long)10,sizeof(numeric),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_date,&(d),(long)1,(long)10,sizeof(date),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_interval,&(in),(long)1,(long)10,sizeof(interval),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
- #line 61 "array.pgc"
- if (sqlca.sqlcode < 0) sqlprint();}
- #line 61 "array.pgc"
- { 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 )",
- =====================================================================
- Found a 15 line (148 tokens) duplication in the following files:
- Starting at line 201 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 341 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
- ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
- #line 70 "cursor.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 70 "cursor.pgc"
- printf("%d %s\n", id, t);
- strcpy(msg, "fetch");
- { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch forward $0",
- =====================================================================
- Found a 34 line (148 tokens) duplication in the following files:
- Starting at line 3329 of /home/shackle/pggit/postgresql/src/backend/optimizer/plan/createplan.c
- Starting at line 2431 of /home/shackle/pggit/postgresql/src/backend/optimizer/path/allpaths.c
- Assert(!rte->self_reference);
- /*
- * Find the referenced CTE, and locate the SubPlan previously made for it.
- */
- levelsup = rte->ctelevelsup;
- cteroot = root;
- while (levelsup-- > 0)
- {
- cteroot = cteroot->parent_root;
- if (!cteroot) /* shouldn't happen */
- elog(ERROR, "bad levelsup for CTE \"%s\"", rte->ctename);
- }
- /*
- * Note: cte_plan_ids can be shorter than cteList, if we are still working
- * on planning the CTEs (ie, this is a side-reference from another CTE).
- * So we mustn't use forboth here.
- */
- ndx = 0;
- foreach(lc, cteroot->parse->cteList)
- {
- CommonTableExpr *cte = (CommonTableExpr *) lfirst(lc);
- if (strcmp(cte->ctename, rte->ctename) == 0)
- break;
- ndx++;
- }
- if (lc == NULL) /* shouldn't happen */
- elog(ERROR, "could not find CTE \"%s\"", rte->ctename);
- if (ndx >= list_length(cteroot->cte_plan_ids))
- elog(ERROR, "could not find plan for CTE \"%s\"", rte->ctename);
- plan_id = list_nth_int(cteroot->cte_plan_ids, ndx);
- Assert(plan_id > 0);
- =====================================================================
- Found a 39 line (148 tokens) duplication in the following files:
- Starting at line 2155 of /home/shackle/pggit/postgresql/src/backend/parser/parse_utilcmd.c
- Starting at line 2278 of /home/shackle/pggit/postgresql/src/backend/parser/parse_utilcmd.c
- RangeVar *inh = castNode(RangeVar, lfirst(inher));
- Relation rel;
- int count;
- rel = heap_openrv(inh, AccessShareLock);
- /* check user requested inheritance from valid relkind */
- if (rel->rd_rel->relkind != RELKIND_RELATION &&
- rel->rd_rel->relkind != RELKIND_FOREIGN_TABLE &&
- rel->rd_rel->relkind != RELKIND_PARTITIONED_TABLE)
- ereport(ERROR,
- (errcode(ERRCODE_WRONG_OBJECT_TYPE),
- errmsg("inherited relation \"%s\" is not a table or foreign table",
- inh->relname)));
- for (count = 0; count < rel->rd_att->natts; count++)
- {
- Form_pg_attribute inhattr = TupleDescAttr(rel->rd_att,
- count);
- char *inhname = NameStr(inhattr->attname);
- if (inhattr->attisdropped)
- continue;
- if (strcmp(key, inhname) == 0)
- {
- found = true;
- /*
- * We currently have no easy way to force an
- * inherited column to be NOT NULL at creation, if
- * its parent wasn't so already. We leave it to
- * DefineIndex to fix things up in this case.
- */
- break;
- }
- }
- heap_close(rel, NoLock);
- if (found)
- break;
- }
- }
- =====================================================================
- Found a 31 line (147 tokens) duplication in the following files:
- Starting at line 1644 of /home/shackle/pggit/postgresql/src/backend/utils/adt/geo_ops.c
- Starting at line 1699 of /home/shackle/pggit/postgresql/src/backend/utils/adt/geo_ops.c
- PG_RETURN_BOOL(false);
- /* pairwise check lseg intersections */
- for (i = 0; i < p1->npts; i++)
- {
- int iprev;
- if (i > 0)
- iprev = i - 1;
- else
- {
- if (!p1->closed)
- continue;
- iprev = p1->npts - 1; /* include the closure segment */
- }
- for (j = 0; j < p2->npts; j++)
- {
- int jprev;
- if (j > 0)
- jprev = j - 1;
- else
- {
- if (!p2->closed)
- continue;
- jprev = p2->npts - 1; /* include the closure segment */
- }
- statlseg_construct(&seg1, &p1->p[iprev], &p1->p[i]);
- statlseg_construct(&seg2, &p2->p[jprev], &p2->p[j]);
- =====================================================================
- Found a 31 line (146 tokens) duplication in the following files:
- Starting at line 99 of /home/shackle/pggit/postgresql/src/tools/findoidjoins/findoidjoins.c
- Starting at line 175 of /home/shackle/pggit/postgresql/src/tools/findoidjoins/findoidjoins.c
- "ORDER BY nspname, c.relname, a.attnum"
- );
- res = PQexec(conn, sql.data);
- if (!res || PQresultStatus(res) != PGRES_TUPLES_OK)
- {
- fprintf(stderr, "sql error: %s\n", PQerrorMessage(conn));
- exit(EXIT_FAILURE);
- }
- fkrel_res = res;
- /*
- * For each column and each relation-having-OIDs, look to see if the
- * column contains any values matching entries in the relation.
- */
- for (fk = 0; fk < PQntuples(fkrel_res); fk++)
- {
- fk_relname = PQgetvalue(fkrel_res, fk, 0);
- fk_nspname = PQgetvalue(fkrel_res, fk, 1);
- fk_attname = PQgetvalue(fkrel_res, fk, 2);
- for (pk = 0; pk < PQntuples(pkrel_res); pk++)
- {
- pk_relname = PQgetvalue(pkrel_res, pk, 0);
- pk_nspname = PQgetvalue(pkrel_res, pk, 1);
- printfPQExpBuffer(&sql,
- "SELECT 1 "
- "FROM \"%s\".\"%s\" t1, "
- "\"%s\".\"%s\" t2 "
- =====================================================================
- Found a 54 line (146 tokens) duplication in the following files:
- Starting at line 729 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/numeric.c
- Starting at line 857 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/numeric.c
- if (var2->sign == NUMERIC_POS)
- {
- /*
- * Both are positive result = +(ABS(var1) + ABS(var2))
- */
- if (add_abs(var1, var2, result) != 0)
- return -1;
- result->sign = NUMERIC_POS;
- }
- else
- {
- /*
- * var1 is positive, var2 is negative Must compare absolute values
- */
- switch (cmp_abs(var1, var2))
- {
- case 0:
- /* ----------
- * ABS(var1) == ABS(var2)
- * result = ZERO
- * ----------
- */
- zero_var(result);
- result->rscale = Max(var1->rscale, var2->rscale);
- result->dscale = Max(var1->dscale, var2->dscale);
- break;
- case 1:
- /* ----------
- * ABS(var1) > ABS(var2)
- * result = +(ABS(var1) - ABS(var2))
- * ----------
- */
- if (sub_abs(var1, var2, result) != 0)
- return -1;
- result->sign = NUMERIC_POS;
- break;
- case -1:
- /* ----------
- * ABS(var1) < ABS(var2)
- * result = -(ABS(var2) - ABS(var1))
- * ----------
- */
- if (sub_abs(var2, var1, result) != 0)
- return -1;
- result->sign = NUMERIC_NEG;
- break;
- }
- }
- }
- else
- {
- if (var2->sign == NUMERIC_POS)
- =====================================================================
- Found a 35 line (146 tokens) duplication in the following files:
- Starting at line 480 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/interval.c
- Starting at line 3243 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
- *fsec += rint((val + fval) * 1000);
- tmask = DTK_M(MILLISECOND);
- break;
- case DTK_SECOND:
- tm->tm_sec += val;
- *fsec += rint(fval * 1000000);
- /*
- * If any subseconds were specified, consider this
- * microsecond and millisecond input as well.
- */
- if (fval == 0)
- tmask = DTK_M(SECOND);
- else
- tmask = DTK_ALL_SECS_M;
- break;
- case DTK_MINUTE:
- tm->tm_min += val;
- AdjustFractSeconds(fval, tm, fsec, SECS_PER_MINUTE);
- tmask = DTK_M(MINUTE);
- break;
- case DTK_HOUR:
- tm->tm_hour += val;
- AdjustFractSeconds(fval, tm, fsec, SECS_PER_HOUR);
- tmask = DTK_M(HOUR);
- type = DTK_DAY;
- break;
- case DTK_DAY:
- tm->tm_mday += val;
- AdjustFractSeconds(fval, tm, fsec, SECS_PER_DAY);
- tmask = (fmask & DTK_M(DAY)) ? 0 : DTK_M(DAY);
- =====================================================================
- Found a 18 line (146 tokens) duplication in the following files:
- Starting at line 881 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/interval.c
- Starting at line 4349 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
- *cp = '\0';
- }
- break;
- /* Compatible with postgresql < 8.4 when DateStyle = 'iso' */
- case INTSTYLE_POSTGRES:
- cp = AddPostgresIntPart(cp, year, "year", &is_zero, &is_before);
- cp = AddPostgresIntPart(cp, mon, "mon", &is_zero, &is_before);
- cp = AddPostgresIntPart(cp, mday, "day", &is_zero, &is_before);
- if (is_zero || hour != 0 || min != 0 || sec != 0 || fsec != 0)
- {
- bool minus = (hour < 0 || min < 0 || sec < 0 || fsec < 0);
- sprintf(cp, "%s%s%02d:%02d:",
- is_zero ? "" : " ",
- (minus ? "-" : (is_before ? "+" : "")),
- abs(hour), abs(min));
- cp += strlen(cp);
- =====================================================================
- Found a 35 line (146 tokens) duplication in the following files:
- Starting at line 1930 of /home/shackle/pggit/postgresql/src/backend/access/heap/tuptoaster.c
- Starting at line 2155 of /home/shackle/pggit/postgresql/src/backend/access/heap/tuptoaster.c
- &SnapshotToast, 1, &toastkey);
- while ((ttup = systable_getnext_ordered(toastscan, ForwardScanDirection)) != NULL)
- {
- /*
- * Have a chunk, extract the sequence number and the data
- */
- residx = DatumGetInt32(fastgetattr(ttup, 2, toasttupDesc, &isnull));
- Assert(!isnull);
- chunk = DatumGetPointer(fastgetattr(ttup, 3, toasttupDesc, &isnull));
- Assert(!isnull);
- if (!VARATT_IS_EXTENDED(chunk))
- {
- chunksize = VARSIZE(chunk) - VARHDRSZ;
- chunkdata = VARDATA(chunk);
- }
- else if (VARATT_IS_SHORT(chunk))
- {
- /* could happen due to heap_form_tuple doing its thing */
- chunksize = VARSIZE_SHORT(chunk) - VARHDRSZ_SHORT;
- chunkdata = VARDATA_SHORT(chunk);
- }
- else
- {
- /* should never happen */
- elog(ERROR, "found toasted toast chunk for toast value %u in %s",
- toast_pointer.va_valueid,
- RelationGetRelationName(toastrel));
- chunksize = 0; /* keep compiler quiet */
- chunkdata = NULL;
- }
- /*
- * Some checks on the data we've found
- */
- if (residx != nextidx)
- =====================================================================
- Found a 26 line (145 tokens) duplication in the following files:
- Starting at line 177 of /home/shackle/pggit/postgresql/src/port/qsort.c
- Starting at line 177 of /home/shackle/pggit/postgresql/src/port/qsort_arg.c
- while (pb <= pc && (r = cmp(pc, a)) >= 0)
- {
- if (r == 0)
- {
- swap(pc, pd);
- pd -= es;
- }
- pc -= es;
- }
- if (pb > pc)
- break;
- swap(pb, pc);
- pb += es;
- pc -= es;
- }
- pn = (char *) a + n * es;
- d1 = Min(pa - (char *) a, pb - pa);
- vecswap(a, pb - d1, d1);
- d1 = Min(pd - pc, pn - pd - es);
- vecswap(pb, pn - d1, d1);
- d1 = pb - pa;
- d2 = pd - pc;
- if (d1 <= d2)
- {
- /* Recurse on left partition, then iterate on right partition */
- if (d1 > es)
- =====================================================================
- Found a 10 line (145 tokens) duplication in the following files:
- Starting at line 221 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-array.c
- Starting at line 297 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-array.c
- ECPGt_char,(text),(long)25,(long)1,(25)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_timestamp,&(ts),(long)1,(long)10,sizeof(timestamp),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_numeric,&(n),(long)1,(long)10,sizeof(numeric),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_date,&(d),(long)1,(long)10,sizeof(date),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_interval,&(in),(long)1,(long)10,sizeof(interval),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
- =====================================================================
- Found a 49 line (145 tokens) duplication in the following files:
- Starting at line 1151 of /home/shackle/pggit/postgresql/src/backend/regex/regexec.c
- Starting at line 1358 of /home/shackle/pggit/postgresql/src/backend/regex/regexec.c
- limit = end;
- continue;
- }
- /*
- * We've identified a way to divide the string into k sub-matches that
- * works so far as the child DFA can tell. If k is an allowed number
- * of matches, start the slow part: recurse to verify each sub-match.
- * We always have k <= max_matches, needn't check that.
- */
- if (k < min_matches)
- goto backtrack;
- MDEBUG(("%d: verifying %d..%d\n", t->id, nverified + 1, k));
- for (i = nverified + 1; i <= k; i++)
- {
- zaptreesubs(v, t->left);
- er = cdissect(v, t->left, endpts[i - 1], endpts[i]);
- if (er == REG_OKAY)
- {
- nverified = i;
- continue;
- }
- if (er == REG_NOMATCH)
- break;
- /* oops, something failed */
- FREE(endpts);
- return er;
- }
- if (i > k)
- {
- /* satisfaction */
- MDEBUG(("%d successful\n", t->id));
- FREE(endpts);
- return REG_OKAY;
- }
- /* match failed to verify, so backtrack */
- backtrack:
- /*
- * Must consider shorter versions of the current sub-match. However,
- * we'll only ask for a zero-length match if necessary.
- */
- while (k > 0)
- {
- =====================================================================
- Found a 33 line (144 tokens) duplication in the following files:
- Starting at line 904 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/ecpglib/execute.c
- Starting at line 951 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/ecpglib/execute.c
- Starting at line 998 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/ecpglib/execute.c
- str = quote_postgres(PGTYPESinterval_to_asc(&(((interval *) (var->value))[element])), quote, lineno);
- if (!str)
- {
- ecpg_free(mallocedval);
- return false;
- }
- slen = strlen(str);
- if (!(newcopy = ecpg_realloc(mallocedval, strlen(mallocedval) + slen + 2, lineno)))
- {
- ecpg_free(mallocedval);
- ecpg_free(str);
- return false;
- }
- mallocedval = newcopy;
- /* also copy trailing '\0' */
- memcpy(mallocedval + strlen(mallocedval), str, slen + 1);
- if (var->arrsize > 1)
- strcpy(mallocedval + strlen(mallocedval), ",");
- ecpg_free(str);
- }
- if (var->arrsize > 1)
- strcpy(mallocedval + strlen(mallocedval) - 1, "}");
- *tobeinserted_p = mallocedval;
- }
- break;
- case ECPGt_date:
- =====================================================================
- Found a 26 line (144 tokens) duplication in the following files:
- Starting at line 1542 of /home/shackle/pggit/postgresql/src/backend/optimizer/plan/setrefs.c
- Starting at line 2441 of /home/shackle/pggit/postgresql/src/backend/optimizer/plan/setrefs.c
- return (Node *) var;
- }
- if (IsA(node, Param))
- return fix_param_node(context->root, (Param *) node);
- if (IsA(node, Aggref))
- {
- Aggref *aggref = (Aggref *) node;
- /* See if the Aggref should be replaced by a Param */
- if (context->root->minmax_aggs != NIL &&
- list_length(aggref->args) == 1)
- {
- TargetEntry *curTarget = (TargetEntry *) linitial(aggref->args);
- ListCell *lc;
- foreach(lc, context->root->minmax_aggs)
- {
- MinMaxAggInfo *mminfo = (MinMaxAggInfo *) lfirst(lc);
- if (mminfo->aggfnoid == aggref->aggfnoid &&
- equal(mminfo->target, curTarget->expr))
- return (Node *) copyObject(mminfo->param);
- }
- }
- /* If no match, just fall through to process it normally */
- }
- =====================================================================
- Found a 27 line (143 tokens) duplication in the following files:
- Starting at line 62 of /home/shackle/pggit/postgresql/src/test/isolation/isolation_main.c
- Starting at line 50 of /home/shackle/pggit/postgresql/src/test/regress/pg_regress_main.c
- snprintf(infile, sizeof(infile), "%s/specs/%s.spec",
- inputdir, testname);
- snprintf(outfile, sizeof(outfile), "%s/results/%s.out",
- outputdir, testname);
- snprintf(expectfile, sizeof(expectfile), "%s/expected/%s.out",
- outputdir, testname);
- if (!file_exists(expectfile))
- snprintf(expectfile, sizeof(expectfile), "%s/expected/%s.out",
- inputdir, testname);
- add_stringlist_item(resultfiles, outfile);
- add_stringlist_item(expectfiles, expectfile);
- if (launcher)
- {
- offset += snprintf(psql_cmd + offset, sizeof(psql_cmd) - offset,
- "%s ", launcher);
- if (offset >= sizeof(psql_cmd))
- {
- fprintf(stderr, _("command too long\n"));
- exit(2);
- }
- }
- offset += snprintf(psql_cmd + offset, sizeof(psql_cmd) - offset,
- =====================================================================
- Found a 68 line (143 tokens) duplication in the following files:
- Starting at line 782 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/numeric.c
- Starting at line 914 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/numeric.c
- if (var2->sign == NUMERIC_POS)
- {
- /* ----------
- * var1 is negative, var2 is positive
- * Must compare absolute values
- * ----------
- */
- switch (cmp_abs(var1, var2))
- {
- case 0:
- /* ----------
- * ABS(var1) == ABS(var2)
- * result = ZERO
- * ----------
- */
- zero_var(result);
- result->rscale = Max(var1->rscale, var2->rscale);
- result->dscale = Max(var1->dscale, var2->dscale);
- break;
- case 1:
- /* ----------
- * ABS(var1) > ABS(var2)
- * result = -(ABS(var1) - ABS(var2))
- * ----------
- */
- if (sub_abs(var1, var2, result) != 0)
- return -1;
- result->sign = NUMERIC_NEG;
- break;
- case -1:
- /* ----------
- * ABS(var1) < ABS(var2)
- * result = +(ABS(var2) - ABS(var1))
- * ----------
- */
- if (sub_abs(var2, var1, result) != 0)
- return -1;
- result->sign = NUMERIC_POS;
- break;
- }
- }
- else
- {
- /* ----------
- * Both are negative
- * result = -(ABS(var1) + ABS(var2))
- * ----------
- */
- if (add_abs(var1, var2, result) != 0)
- return -1;
- result->sign = NUMERIC_NEG;
- }
- }
- return 0;
- }
- /* ----------
- * sub_var() -
- *
- * Full version of sub functionality on variable level (handling signs).
- * result might point to one of the operands too without danger.
- * ----------
- */
- int
- =====================================================================
- Found a 12 line (143 tokens) duplication in the following files:
- Starting at line 1737 of /home/shackle/pggit/postgresql/src/backend/utils/mb/wchar.c
- Starting at line 1754 of /home/shackle/pggit/postgresql/src/backend/utils/mb/wchar.c
- {pg_mule2wchar_with_len, pg_wchar2mule_with_len, pg_mule_mblen, pg_mule_dsplen, pg_mule_verifier, 4}, /* PG_MULE_INTERNAL */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN1 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN2 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN3 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN4 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN5 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN6 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN7 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN8 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN9 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN10 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_WIN1256 */
- =====================================================================
- Found a 30 line (143 tokens) duplication in the following files:
- Starting at line 1584 of /home/shackle/pggit/postgresql/src/backend/utils/adt/formatting.c
- Starting at line 1706 of /home/shackle/pggit/postgresql/src/backend/utils/adt/formatting.c
- len_conv = icu_convert_case(u_strToLower, mylocale,
- &buff_conv, buff_uchar, len_uchar);
- icu_from_uchar(&result, buff_conv, len_conv);
- pfree(buff_uchar);
- }
- else
- #endif
- {
- if (pg_database_encoding_max_length() > 1)
- {
- wchar_t *workspace;
- size_t curr_char;
- size_t result_size;
- /* Overflow paranoia */
- if ((nbytes + 1) > (INT_MAX / sizeof(wchar_t)))
- ereport(ERROR,
- (errcode(ERRCODE_OUT_OF_MEMORY),
- errmsg("out of memory")));
- /* Output workspace cannot have more codes than input bytes */
- workspace = (wchar_t *) palloc((nbytes + 1) * sizeof(wchar_t));
- char2wchar(workspace, nbytes + 1, buff, nbytes, mylocale);
- for (curr_char = 0; workspace[curr_char] != 0; curr_char++)
- {
- #ifdef HAVE_LOCALE_T
- if (mylocale)
- workspace[curr_char] = towlower_l(workspace[curr_char], mylocale->info.lt);
- =====================================================================
- Found a 39 line (143 tokens) duplication in the following files:
- Starting at line 5494 of /home/shackle/pggit/postgresql/src/backend/utils/adt/formatting.c
- Starting at line 5802 of /home/shackle/pggit/postgresql/src/backend/utils/adt/formatting.c
- NumericGetDatum(x)));
- if (*orgnum == '-')
- {
- sign = '-';
- numstr = orgnum + 1;
- }
- else
- {
- sign = '+';
- numstr = orgnum;
- }
- if ((p = strchr(numstr, '.')))
- numstr_pre_len = p - numstr;
- else
- numstr_pre_len = strlen(numstr);
- /* needs padding? */
- if (numstr_pre_len < Num.pre)
- out_pre_spaces = Num.pre - numstr_pre_len;
- /* overflowed prefix digit format? */
- else if (numstr_pre_len > Num.pre)
- {
- numstr = (char *) palloc(Num.pre + Num.post + 2);
- fill_str(numstr, '#', Num.pre + Num.post + 1);
- *(numstr + Num.pre) = '.';
- }
- }
- NUM_TOCHAR_finish;
- PG_RETURN_TEXT_P(result);
- }
- /* ---------------
- * INT4 to_char()
- * ---------------
- */
- Datum
- =====================================================================
- Found a 22 line (143 tokens) duplication in the following files:
- Starting at line 481 of /home/shackle/pggit/postgresql/src/backend/utils/error/elog.c
- Starting at line 1540 of /home/shackle/pggit/postgresql/src/backend/utils/error/elog.c
- if (edata->message)
- pfree(edata->message);
- if (edata->detail)
- pfree(edata->detail);
- if (edata->detail_log)
- pfree(edata->detail_log);
- if (edata->hint)
- pfree(edata->hint);
- if (edata->context)
- pfree(edata->context);
- if (edata->schema_name)
- pfree(edata->schema_name);
- if (edata->table_name)
- pfree(edata->table_name);
- if (edata->column_name)
- pfree(edata->column_name);
- if (edata->datatype_name)
- pfree(edata->datatype_name);
- if (edata->constraint_name)
- pfree(edata->constraint_name);
- if (edata->internalquery)
- pfree(edata->internalquery);
- =====================================================================
- Found a 30 line (142 tokens) duplication in the following files:
- Starting at line 186 of /home/shackle/pggit/postgresql/contrib/hstore/hstore_gist.c
- Starting at line 105 of /home/shackle/pggit/postgresql/contrib/intarray/_intbig_gist.c
- ghstore_same(PG_FUNCTION_ARGS)
- {
- GISTTYPE *a = (GISTTYPE *) PG_GETARG_POINTER(0);
- GISTTYPE *b = (GISTTYPE *) PG_GETARG_POINTER(1);
- bool *result = (bool *) PG_GETARG_POINTER(2);
- if (ISALLTRUE(a) && ISALLTRUE(b))
- *result = true;
- else if (ISALLTRUE(a))
- *result = false;
- else if (ISALLTRUE(b))
- *result = false;
- else
- {
- int32 i;
- BITVECP sa = GETSIGN(a),
- sb = GETSIGN(b);
- *result = true;
- LOOPBYTE
- {
- if (sa[i] != sb[i])
- {
- *result = false;
- break;
- }
- }
- }
- PG_RETURN_POINTER(result);
- }
- =====================================================================
- Found a 30 line (142 tokens) duplication in the following files:
- Starting at line 809 of /home/shackle/pggit/postgresql/contrib/hstore/hstore_io.c
- Starting at line 110 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
- Starting at line 483 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
- tupdesc = lookup_rowtype_tupdesc_domain(tupType, tupTypmod, false);
- ncolumns = tupdesc->natts;
- /*
- * We arrange to look up the needed I/O info just once per series of
- * calls, assuming the record type doesn't change underneath us.
- */
- my_extra = (RecordIOData *) fcinfo->flinfo->fn_extra;
- if (my_extra == NULL ||
- my_extra->ncolumns != ncolumns)
- {
- fcinfo->flinfo->fn_extra =
- MemoryContextAlloc(fcinfo->flinfo->fn_mcxt,
- offsetof(RecordIOData, columns) +
- ncolumns * sizeof(ColumnIOData));
- my_extra = (RecordIOData *) fcinfo->flinfo->fn_extra;
- my_extra->record_type = InvalidOid;
- my_extra->record_typmod = 0;
- }
- if (my_extra->record_type != tupType ||
- my_extra->record_typmod != tupTypmod)
- {
- MemSet(my_extra, 0,
- offsetof(RecordIOData, columns) +
- ncolumns * sizeof(ColumnIOData));
- my_extra->record_type = tupType;
- my_extra->record_typmod = tupTypmod;
- my_extra->ncolumns = ncolumns;
- }
- =====================================================================
- Found a 77 line (142 tokens) duplication in the following files:
- Starting at line 1315 of /home/shackle/pggit/postgresql/src/backend/utils/sort/tuplesort.c
- Starting at line 578 of /home/shackle/pggit/postgresql/src/backend/utils/sort/tuplestore.c
- grow_memtuples(Tuplesortstate *state)
- {
- int newmemtupsize;
- int memtupsize = state->memtupsize;
- int64 memNowUsed = state->allowedMem - state->availMem;
- /* Forget it if we've already maxed out memtuples, per comment above */
- if (!state->growmemtuples)
- return false;
- /* Select new value of memtupsize */
- if (memNowUsed <= state->availMem)
- {
- /*
- * We've used no more than half of allowedMem; double our usage,
- * clamping at INT_MAX tuples.
- */
- if (memtupsize < INT_MAX / 2)
- newmemtupsize = memtupsize * 2;
- else
- {
- newmemtupsize = INT_MAX;
- state->growmemtuples = false;
- }
- }
- else
- {
- /*
- * This will be the last increment of memtupsize. Abandon doubling
- * strategy and instead increase as much as we safely can.
- *
- * To stay within allowedMem, we can't increase memtupsize by more
- * than availMem / sizeof(SortTuple) elements. In practice, we want
- * to increase it by considerably less, because we need to leave some
- * space for the tuples to which the new array slots will refer. We
- * assume the new tuples will be about the same size as the tuples
- * we've already seen, and thus we can extrapolate from the space
- * consumption so far to estimate an appropriate new size for the
- * memtuples array. The optimal value might be higher or lower than
- * this estimate, but it's hard to know that in advance. We again
- * clamp at INT_MAX tuples.
- *
- * This calculation is safe against enlarging the array so much that
- * LACKMEM becomes true, because the memory currently used includes
- * the present array; thus, there would be enough allowedMem for the
- * new array elements even if no other memory were currently used.
- *
- * We do the arithmetic in float8, because otherwise the product of
- * memtupsize and allowedMem could overflow. Any inaccuracy in the
- * result should be insignificant; but even if we computed a
- * completely insane result, the checks below will prevent anything
- * really bad from happening.
- */
- double grow_ratio;
- grow_ratio = (double) state->allowedMem / (double) memNowUsed;
- if (memtupsize * grow_ratio < INT_MAX)
- newmemtupsize = (int) (memtupsize * grow_ratio);
- else
- newmemtupsize = INT_MAX;
- /* We won't make any further enlargement attempts */
- state->growmemtuples = false;
- }
- /* Must enlarge array by at least one element, else report failure */
- if (newmemtupsize <= memtupsize)
- goto noalloc;
- /*
- * On a 32-bit machine, allowedMem could exceed MaxAllocHugeSize. Clamp
- * to ensure our request won't be rejected. Note that we can easily
- * exhaust address space before facing this outcome. (This is presently
- * impossible due to guc.c's MAX_KILOBYTES limitation on work_mem, but
- * don't rely on that at this distance.)
- */
- if ((Size) newmemtupsize >= MaxAllocHugeSize / sizeof(SortTuple))
- =====================================================================
- Found a 33 line (142 tokens) duplication in the following files:
- Starting at line 5494 of /home/shackle/pggit/postgresql/src/backend/utils/adt/formatting.c
- Starting at line 5905 of /home/shackle/pggit/postgresql/src/backend/utils/adt/formatting.c
- NumericGetDatum(x)));
- if (*orgnum == '-')
- {
- sign = '-';
- numstr = orgnum + 1;
- }
- else
- {
- sign = '+';
- numstr = orgnum;
- }
- if ((p = strchr(numstr, '.')))
- numstr_pre_len = p - numstr;
- else
- numstr_pre_len = strlen(numstr);
- /* needs padding? */
- if (numstr_pre_len < Num.pre)
- out_pre_spaces = Num.pre - numstr_pre_len;
- /* overflowed prefix digit format? */
- else if (numstr_pre_len > Num.pre)
- {
- numstr = (char *) palloc(Num.pre + Num.post + 2);
- fill_str(numstr, '#', Num.pre + Num.post + 1);
- *(numstr + Num.pre) = '.';
- }
- }
- NUM_TOCHAR_finish;
- PG_RETURN_TEXT_P(result);
- }
- =====================================================================
- Found a 42 line (142 tokens) duplication in the following files:
- Starting at line 3417 of /home/shackle/pggit/postgresql/src/backend/utils/adt/varlena.c
- Starting at line 3538 of /home/shackle/pggit/postgresql/src/backend/utils/adt/varlena.c
- SplitDirectoriesString(char *rawstring, char separator,
- List **namelist)
- {
- char *nextp = rawstring;
- bool done = false;
- *namelist = NIL;
- while (scanner_isspace(*nextp))
- nextp++; /* skip leading whitespace */
- if (*nextp == '\0')
- return true; /* allow empty string */
- /* At the top of the loop, we are at start of a new directory. */
- do
- {
- char *curname;
- char *endp;
- if (*nextp == '"')
- {
- /* Quoted name --- collapse quote-quote pairs */
- curname = nextp + 1;
- for (;;)
- {
- endp = strchr(nextp + 1, '"');
- if (endp == NULL)
- return false; /* mismatched quotes */
- if (endp[1] != '"')
- break; /* found end of quoted name */
- /* Collapse adjacent quotes into one quote, and look again */
- memmove(endp, endp + 1, strlen(endp));
- nextp = endp;
- }
- /* endp now points at the terminating quote */
- nextp = endp + 1;
- }
- else
- {
- /* Unquoted name --- extends to separator or end of string */
- curname = endp = nextp;
- =====================================================================
- Found a 27 line (141 tokens) duplication in the following files:
- Starting at line 308 of /home/shackle/pggit/postgresql/contrib/hstore/hstore_gist.c
- Starting at line 301 of /home/shackle/pggit/postgresql/contrib/intarray/_intbig_gist.c
- ghstore_penalty(PG_FUNCTION_ARGS)
- {
- GISTENTRY *origentry = (GISTENTRY *) PG_GETARG_POINTER(0); /* always ISSIGNKEY */
- GISTENTRY *newentry = (GISTENTRY *) PG_GETARG_POINTER(1);
- float *penalty = (float *) PG_GETARG_POINTER(2);
- GISTTYPE *origval = (GISTTYPE *) DatumGetPointer(origentry->key);
- GISTTYPE *newval = (GISTTYPE *) DatumGetPointer(newentry->key);
- *penalty = hemdist(origval, newval);
- PG_RETURN_POINTER(penalty);
- }
- typedef struct
- {
- OffsetNumber pos;
- int32 cost;
- } SPLITCOST;
- static int
- comparecost(const void *a, const void *b)
- {
- return ((const SPLITCOST *) a)->cost - ((const SPLITCOST *) b)->cost;
- }
- Datum
- =====================================================================
- Found a 3 line (141 tokens) duplication in the following files:
- Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
- Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- =====================================================================
- Found a 3 line (141 tokens) duplication in the following files:
- Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
- Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- =====================================================================
- Found a 22 line (141 tokens) duplication in the following files:
- Starting at line 261 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/compat_informix-describe.c
- Starting at line 388 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-describe.c
- for (i = 1; i <= count1; i++)
- {
- { ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
- ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
- #line 115 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 115 "describe.pgc"
- { ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
- ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
- #line 116 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 116 "describe.pgc"
- printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
- "sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n",
- i, field_name1, field_name2,
- sqlda1->sqlvar[i-1].sqlname,
- =====================================================================
- Found a 22 line (141 tokens) duplication in the following files:
- Starting at line 390 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/compat_informix-describe.c
- Starting at line 259 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-describe.c
- for (i = 1; i <= count1; i++)
- {
- { ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
- ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
- #line 168 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 168 "describe.pgc"
- { ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
- ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
- #line 169 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 169 "describe.pgc"
- printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
- "sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n",
- i, field_name1, field_name2,
- sqlda1->sqlvar[i-1].sqlname,
- =====================================================================
- Found a 23 line (141 tokens) duplication in the following files:
- Starting at line 49 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-show.c
- Starting at line 71 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-show.c
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
- #line 18 "show.pgc"
- if (sqlca.sqlwarn[0] == 'W') sqlprint();
- #line 18 "show.pgc"
- if (sqlca.sqlcode < 0) sqlprint();}
- #line 18 "show.pgc"
- { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "show search_path", ECPGt_EOIT,
- ECPGt_char,(var),(long)25,(long)1,(25)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
- #line 19 "show.pgc"
- if (sqlca.sqlwarn[0] == 'W') sqlprint();
- #line 19 "show.pgc"
- if (sqlca.sqlcode < 0) sqlprint();}
- #line 19 "show.pgc"
- printf("Var: Search path: %s\n", var);
- { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set search_path to 'public'", ECPGt_EOIT, ECPGt_EORT);
- =====================================================================
- Found a 25 line (141 tokens) duplication in the following files:
- Starting at line 64 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-quote.c
- Starting at line 108 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-quote.c
- { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set standard_conforming_strings to off", ECPGt_EOIT, ECPGt_EORT);
- #line 22 "quote.pgc"
- if (sqlca.sqlwarn[0] == 'W') sqlprint();
- #line 22 "quote.pgc"
- if (sqlca.sqlcode < 0) sqlprint();}
- #line 22 "quote.pgc"
- { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "show standard_conforming_strings", ECPGt_EOIT,
- ECPGt_char,(var),(long)25,(long)1,(25)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
- #line 24 "quote.pgc"
- if (sqlca.sqlwarn[0] == 'W') sqlprint();
- #line 24 "quote.pgc"
- if (sqlca.sqlcode < 0) sqlprint();}
- #line 24 "quote.pgc"
- printf("Standard conforming strings: %s\n", var);
- /* this is a\\b actually */
- { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into \"My_Table\" values ( 1 , 'a\\\\\\\\b' )", ECPGt_EOIT, ECPGt_EORT);
- =====================================================================
- Found a 39 line (141 tokens) duplication in the following files:
- Starting at line 363 of /home/shackle/pggit/postgresql/src/backend/executor/nodeWindowAgg.c
- Starting at line 529 of /home/shackle/pggit/postgresql/src/backend/executor/nodeWindowAgg.c
- peraggstate->transValueCount++;
- /*
- * If pass-by-ref datatype, must copy the new value into aggcontext and
- * free the prior transValue. But if transfn returned a pointer to its
- * first input, we don't need to do anything. Also, if transfn returned a
- * pointer to a R/W expanded object that is already a child of the
- * aggcontext, assume we can adopt that value without copying it.
- */
- if (!peraggstate->transtypeByVal &&
- DatumGetPointer(newVal) != DatumGetPointer(peraggstate->transValue))
- {
- if (!fcinfo->isnull)
- {
- MemoryContextSwitchTo(peraggstate->aggcontext);
- if (DatumIsReadWriteExpandedObject(newVal,
- false,
- peraggstate->transtypeLen) &&
- MemoryContextGetParent(DatumGetEOHP(newVal)->eoh_context) == CurrentMemoryContext)
- /* do nothing */ ;
- else
- newVal = datumCopy(newVal,
- peraggstate->transtypeByVal,
- peraggstate->transtypeLen);
- }
- if (!peraggstate->transValueIsNull)
- {
- if (DatumIsReadWriteExpandedObject(peraggstate->transValue,
- false,
- peraggstate->transtypeLen))
- DeleteExpandedObject(peraggstate->transValue);
- else
- pfree(DatumGetPointer(peraggstate->transValue));
- }
- }
- MemoryContextSwitchTo(oldContext);
- peraggstate->transValue = newVal;
- peraggstate->transValueIsNull = fcinfo->isnull;
- =====================================================================
- Found a 33 line (141 tokens) duplication in the following files:
- Starting at line 1279 of /home/shackle/pggit/postgresql/src/backend/executor/nodeIndexscan.c
- Starting at line 1409 of /home/shackle/pggit/postgresql/src/backend/executor/nodeIndexscan.c
- rightop = (Expr *) get_rightop(clause);
- if (rightop && IsA(rightop, RelabelType))
- rightop = ((RelabelType *) rightop)->arg;
- Assert(rightop != NULL);
- if (IsA(rightop, Const))
- {
- /* OK, simple constant comparison value */
- scanvalue = ((Const *) rightop)->constvalue;
- if (((Const *) rightop)->constisnull)
- flags |= SK_ISNULL;
- }
- else
- {
- /* Need to treat this one as a runtime key */
- if (n_runtime_keys >= max_runtime_keys)
- {
- if (max_runtime_keys == 0)
- {
- max_runtime_keys = 8;
- runtime_keys = (IndexRuntimeKeyInfo *)
- palloc(max_runtime_keys * sizeof(IndexRuntimeKeyInfo));
- }
- else
- {
- max_runtime_keys *= 2;
- runtime_keys = (IndexRuntimeKeyInfo *)
- repalloc(runtime_keys, max_runtime_keys * sizeof(IndexRuntimeKeyInfo));
- }
- }
- runtime_keys[n_runtime_keys].scan_key = this_scan_key;
- =====================================================================
- Found a 46 line (141 tokens) duplication in the following files:
- Starting at line 1321 of /home/shackle/pggit/postgresql/src/backend/utils/adt/int8.c
- Starting at line 1375 of /home/shackle/pggit/postgresql/src/backend/utils/adt/int.c
- step = PG_GETARG_INT64(2);
- if (step == 0)
- ereport(ERROR,
- (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("step size cannot equal zero")));
- /* create a function context for cross-call persistence */
- funcctx = SRF_FIRSTCALL_INIT();
- /*
- * switch to memory context appropriate for multiple function calls
- */
- oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
- /* allocate memory for user context */
- fctx = (generate_series_fctx *) palloc(sizeof(generate_series_fctx));
- /*
- * Use fctx to keep state from call to call. Seed current with the
- * original start value
- */
- fctx->current = start;
- fctx->finish = finish;
- fctx->step = step;
- funcctx->user_fctx = fctx;
- MemoryContextSwitchTo(oldcontext);
- }
- /* stuff done on every call of the function */
- funcctx = SRF_PERCALL_SETUP();
- /*
- * get the saved state and use current as the result for this iteration
- */
- fctx = funcctx->user_fctx;
- result = fctx->current;
- if ((fctx->step > 0 && fctx->current <= fctx->finish) ||
- (fctx->step < 0 && fctx->current >= fctx->finish))
- {
- /*
- * Increment current in preparation for next iteration. If next-value
- * computation overflows, this is the final result.
- */
- if (pg_add_s64_overflow(fctx->current, fctx->step, &fctx->current))
- =====================================================================
- Found a 26 line (141 tokens) duplication in the following files:
- Starting at line 47 of /home/shackle/pggit/postgresql/src/backend/utils/adt/jsonb_op.c
- Starting at line 80 of /home/shackle/pggit/postgresql/src/backend/utils/adt/jsonb_op.c
- jsonb_exists_any(PG_FUNCTION_ARGS)
- {
- Jsonb *jb = PG_GETARG_JSONB_P(0);
- ArrayType *keys = PG_GETARG_ARRAYTYPE_P(1);
- int i;
- Datum *key_datums;
- bool *key_nulls;
- int elem_count;
- deconstruct_array(keys, TEXTOID, -1, false, 'i', &key_datums, &key_nulls,
- &elem_count);
- for (i = 0; i < elem_count; i++)
- {
- JsonbValue strVal;
- if (key_nulls[i])
- continue;
- strVal.type = jbvString;
- strVal.val.string.val = VARDATA(key_datums[i]);
- strVal.val.string.len = VARSIZE(key_datums[i]) - VARHDRSZ;
- if (findJsonbValueFromContainer(&jb->root,
- JB_FOBJECT | JB_FARRAY,
- &strVal) != NULL)
- =====================================================================
- Found a 19 line (141 tokens) duplication in the following files:
- Starting at line 177 of /home/shackle/pggit/postgresql/src/backend/access/common/tupconvert.c
- Starting at line 219 of /home/shackle/pggit/postgresql/src/backend/access/common/tupconvert.c
- return NULL;
- }
- /* Prepare the map structure */
- map = (TupleConversionMap *) palloc(sizeof(TupleConversionMap));
- map->indesc = indesc;
- map->outdesc = outdesc;
- map->attrMap = attrMap;
- /* preallocate workspace for Datum arrays */
- map->outvalues = (Datum *) palloc(n * sizeof(Datum));
- map->outisnull = (bool *) palloc(n * sizeof(bool));
- n = indesc->natts + 1; /* +1 for NULL */
- map->invalues = (Datum *) palloc(n * sizeof(Datum));
- map->inisnull = (bool *) palloc(n * sizeof(bool));
- map->invalues[0] = (Datum) 0; /* set up the NULL entry */
- map->inisnull[0] = true;
- return map;
- }
- =====================================================================
- Found a 18 line (140 tokens) duplication in the following files:
- Starting at line 246 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/thread-prep.c
- Starting at line 205 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/thread-alloc.c
- for (i = 0; i < THREADS; ++i)
- {
- unsigned id;
- threads[i] = (HANDLE)_beginthreadex(NULL, 0, fn, (void*)i, 0, &id);
- }
- WaitForMultipleObjects(THREADS, threads, TRUE, INFINITE);
- for (i = 0; i < THREADS; ++i)
- CloseHandle(threads[i]);
- #else
- for (i = 0; i < THREADS; ++i)
- pthread_create(&threads[i], NULL, fn, (void *) (long) i);
- for (i = 0; i < THREADS; ++i)
- pthread_join(threads[i], NULL);
- #endif
- return 0;
- }
- =====================================================================
- Found a 20 line (140 tokens) duplication in the following files:
- Starting at line 2046 of /home/shackle/pggit/postgresql/src/backend/tsearch/wparser_def.c
- Starting at line 2417 of /home/shackle/pggit/postgresql/src/backend/tsearch/wparser_def.c
- for (i = startpos; i <= endpos; i++)
- {
- if (prs->words[i].item)
- prs->words[i].selected = 1;
- if (highlight == 0)
- {
- if (HLIDREPLACE(prs->words[i].type))
- prs->words[i].replace = 1;
- else if (HLIDSKIP(prs->words[i].type))
- prs->words[i].skip = 1;
- }
- else
- {
- if (XMLHLIDSKIP(prs->words[i].type))
- prs->words[i].skip = 1;
- }
- prs->words[i].in = (prs->words[i].repeated) ? 0 : 1;
- }
- }
- =====================================================================
- Found a 38 line (140 tokens) duplication in the following files:
- Starting at line 5399 of /home/shackle/pggit/postgresql/src/backend/utils/adt/timestamp.c
- Starting at line 5480 of /home/shackle/pggit/postgresql/src/backend/utils/adt/timestamp.c
- palloc(sizeof(generate_series_timestamp_fctx));
- /*
- * Use fctx to keep state from call to call. Seed current with the
- * original start value
- */
- fctx->current = start;
- fctx->finish = finish;
- fctx->step = *step;
- /* Determine sign of the interval */
- MemSet(&interval_zero, 0, sizeof(Interval));
- fctx->step_sign = interval_cmp_internal(&fctx->step, &interval_zero);
- if (fctx->step_sign == 0)
- ereport(ERROR,
- (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("step size cannot equal zero")));
- funcctx->user_fctx = fctx;
- MemoryContextSwitchTo(oldcontext);
- }
- /* stuff done on every call of the function */
- funcctx = SRF_PERCALL_SETUP();
- /*
- * get the saved state and use current as the result for this iteration
- */
- fctx = funcctx->user_fctx;
- result = fctx->current;
- if (fctx->step_sign > 0 ?
- timestamp_cmp_internal(result, fctx->finish) <= 0 :
- timestamp_cmp_internal(result, fctx->finish) >= 0)
- {
- /* increment current in preparation for next iteration */
- fctx->current = DatumGetTimestamp(
- =====================================================================
- Found a 40 line (140 tokens) duplication in the following files:
- Starting at line 3290 of /home/shackle/pggit/postgresql/src/backend/utils/adt/varlena.c
- Starting at line 3417 of /home/shackle/pggit/postgresql/src/backend/utils/adt/varlena.c
- Starting at line 3538 of /home/shackle/pggit/postgresql/src/backend/utils/adt/varlena.c
- SplitIdentifierString(char *rawstring, char separator,
- List **namelist)
- {
- char *nextp = rawstring;
- bool done = false;
- *namelist = NIL;
- while (scanner_isspace(*nextp))
- nextp++; /* skip leading whitespace */
- if (*nextp == '\0')
- return true; /* allow empty string */
- /* At the top of the loop, we are at start of a new identifier. */
- do
- {
- char *curname;
- char *endp;
- if (*nextp == '"')
- {
- /* Quoted name --- collapse quote-quote pairs, no downcasing */
- curname = nextp + 1;
- for (;;)
- {
- endp = strchr(nextp + 1, '"');
- if (endp == NULL)
- return false; /* mismatched quotes */
- if (endp[1] != '"')
- break; /* found end of quoted name */
- /* Collapse adjacent quotes into one quote, and look again */
- memmove(endp, endp + 1, strlen(endp));
- nextp = endp;
- }
- /* endp now points at the terminating quote */
- nextp = endp + 1;
- }
- else
- {
- =====================================================================
- Found a 43 line (140 tokens) duplication in the following files:
- Starting at line 988 of /home/shackle/pggit/postgresql/src/backend/commands/typecmds.c
- Starting at line 2569 of /home/shackle/pggit/postgresql/src/backend/commands/typecmds.c
- break;
- /*
- * All else are error cases
- */
- case CONSTR_UNIQUE:
- ereport(ERROR,
- (errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("unique constraints not possible for domains")));
- break;
- case CONSTR_PRIMARY:
- ereport(ERROR,
- (errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("primary key constraints not possible for domains")));
- break;
- case CONSTR_EXCLUSION:
- ereport(ERROR,
- (errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("exclusion constraints not possible for domains")));
- break;
- case CONSTR_FOREIGN:
- ereport(ERROR,
- (errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("foreign key constraints not possible for domains")));
- break;
- case CONSTR_ATTR_DEFERRABLE:
- case CONSTR_ATTR_NOT_DEFERRABLE:
- case CONSTR_ATTR_DEFERRED:
- case CONSTR_ATTR_IMMEDIATE:
- ereport(ERROR,
- (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("specifying constraint deferrability not supported for domains")));
- break;
- default:
- elog(ERROR, "unrecognized constraint subtype: %d",
- (int) constr->contype);
- break;
- }
- =====================================================================
- Found a 41 line (140 tokens) duplication in the following files:
- Starting at line 4124 of /home/shackle/pggit/postgresql/src/backend/commands/copy.c
- Starting at line 4354 of /home/shackle/pggit/postgresql/src/backend/commands/copy.c
- char delimc = cstate->delim[0];
- int fieldno;
- char *output_ptr;
- char *cur_ptr;
- char *line_end_ptr;
- /*
- * We need a special case for zero-column tables: check that the input
- * line is empty, and return.
- */
- if (cstate->max_fields <= 0)
- {
- if (cstate->line_buf.len != 0)
- ereport(ERROR,
- (errcode(ERRCODE_BAD_COPY_FILE_FORMAT),
- errmsg("extra data after last expected column")));
- return 0;
- }
- resetStringInfo(&cstate->attribute_buf);
- /*
- * The de-escaped attributes will certainly not be longer than the input
- * data line, so we can just force attribute_buf to be large enough and
- * then transfer data without any checks for enough space. We need to do
- * it this way because enlarging attribute_buf mid-stream would invalidate
- * pointers already stored into cstate->raw_fields[].
- */
- if (cstate->attribute_buf.maxlen <= cstate->line_buf.len)
- enlargeStringInfo(&cstate->attribute_buf, cstate->line_buf.len);
- output_ptr = cstate->attribute_buf.data;
- /* set pointer variables for loop */
- cur_ptr = cstate->line_buf.data;
- line_end_ptr = cstate->line_buf.data + cstate->line_buf.len;
- /* Outer loop iterates over fields */
- fieldno = 0;
- for (;;)
- {
- bool found_delim = false;
- =====================================================================
- Found a 14 line (139 tokens) duplication in the following files:
- Starting at line 119 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-binary.c
- Starting at line 150 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-binary.c
- { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch C", ECPGt_EOIT,
- ECPGt_char,(empl.name),(long)21,(long)1,(21)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_short,&(empl.accs),(long)1,(long)1,sizeof(short),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_char,(empl.byte),(long)20,(long)1,(20)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
- #line 60 "binary.pgc"
- if (sqlca.sqlcode)
- {
- printf ("fetch error = %ld\n", sqlca.sqlcode);
- exit (sqlca.sqlcode);
- }
- =====================================================================
- Found a 20 line (139 tokens) duplication in the following files:
- Starting at line 1243 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
- Starting at line 1553 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
- InitFunctionCallInfoData(fcinfo, flinfo, 6, collation, NULL, NULL);
- fcinfo.arg[0] = arg1;
- fcinfo.arg[1] = arg2;
- fcinfo.arg[2] = arg3;
- fcinfo.arg[3] = arg4;
- fcinfo.arg[4] = arg5;
- fcinfo.arg[5] = arg6;
- fcinfo.argnull[0] = false;
- fcinfo.argnull[1] = false;
- fcinfo.argnull[2] = false;
- fcinfo.argnull[3] = false;
- fcinfo.argnull[4] = false;
- fcinfo.argnull[5] = false;
- result = FunctionCallInvoke(&fcinfo);
- /* Check for null result, since caller is clearly not expecting one */
- if (fcinfo.isnull)
- elog(ERROR, "function %u returned NULL", fcinfo.flinfo->fn_oid);
- =====================================================================
- Found a 24 line (139 tokens) duplication in the following files:
- Starting at line 8626 of /home/shackle/pggit/postgresql/src/backend/utils/adt/numeric.c
- Starting at line 8711 of /home/shackle/pggit/postgresql/src/backend/utils/adt/numeric.c
- res_weight = Max(var1->weight, var2->weight) + 1;
- res_dscale = Max(var1->dscale, var2->dscale);
- /* Note: here we are figuring rscale in base-NBASE digits */
- rscale1 = var1->ndigits - var1->weight - 1;
- rscale2 = var2->ndigits - var2->weight - 1;
- res_rscale = Max(rscale1, rscale2);
- res_ndigits = res_rscale + res_weight + 1;
- if (res_ndigits <= 0)
- res_ndigits = 1;
- res_buf = digitbuf_alloc(res_ndigits + 1);
- res_buf[0] = 0; /* spare digit for later rounding */
- res_digits = res_buf + 1;
- i1 = res_rscale + var1->weight + 1;
- i2 = res_rscale + var2->weight + 1;
- for (i = res_ndigits - 1; i >= 0; i--)
- {
- i1--;
- i2--;
- if (i1 >= 0 && i1 < var1ndigits)
- =====================================================================
- Found a 38 line (139 tokens) duplication in the following files:
- Starting at line 109 of /home/shackle/pggit/postgresql/src/backend/utils/adt/expandedrecord.c
- Starting at line 242 of /home/shackle/pggit/postgresql/src/backend/utils/adt/expandedrecord.c
- tupdesc_id = assign_record_type_identifier(type_id, typmod);
- }
- /*
- * Allocate private context for expanded object. We use a regular-size
- * context, not a small one, to improve the odds that we can fit a tupdesc
- * into it without needing an extra malloc block. (This code path doesn't
- * ever need to copy a tupdesc into the expanded record, but let's be
- * consistent with the other ways of making an expanded record.)
- */
- objcxt = AllocSetContextCreate(parentcontext,
- "expanded record",
- ALLOCSET_DEFAULT_SIZES);
- /*
- * Since we already know the number of fields in the tupdesc, we can
- * allocate the dvalues/dnulls arrays along with the record header. This
- * is useless if we never need those arrays, but it costs almost nothing,
- * and it will save a palloc cycle if we do need them.
- */
- erh = (ExpandedRecordHeader *)
- MemoryContextAlloc(objcxt, MAXALIGN(sizeof(ExpandedRecordHeader))
- + tupdesc->natts * (sizeof(Datum) + sizeof(bool)));
- /* Ensure all header fields are initialized to 0/null */
- memset(erh, 0, sizeof(ExpandedRecordHeader));
- EOH_init_header(&erh->hdr, &ER_methods, objcxt);
- erh->er_magic = ER_MAGIC;
- /* Set up dvalues/dnulls, with no valid contents as yet */
- chunk = (char *) erh + MAXALIGN(sizeof(ExpandedRecordHeader));
- erh->dvalues = (Datum *) chunk;
- erh->dnulls = (bool *) (chunk + tupdesc->natts * sizeof(Datum));
- erh->nfields = tupdesc->natts;
- /* Fill in composite-type identification info */
- erh->er_decltypeid = type_id;
- =====================================================================
- Found a 31 line (138 tokens) duplication in the following files:
- Starting at line 110 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_backup_custom.c
- Starting at line 111 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_backup_directory.c
- InitArchiveFmt_Custom(ArchiveHandle *AH)
- {
- lclContext *ctx;
- /* Assuming static functions, this can be copied for each format. */
- AH->ArchiveEntryPtr = _ArchiveEntry;
- AH->StartDataPtr = _StartData;
- AH->WriteDataPtr = _WriteData;
- AH->EndDataPtr = _EndData;
- AH->WriteBytePtr = _WriteByte;
- AH->ReadBytePtr = _ReadByte;
- AH->WriteBufPtr = _WriteBuf;
- AH->ReadBufPtr = _ReadBuf;
- AH->ClosePtr = _CloseArchive;
- AH->ReopenPtr = _ReopenArchive;
- AH->PrintTocDataPtr = _PrintTocData;
- AH->ReadExtraTocPtr = _ReadExtraToc;
- AH->WriteExtraTocPtr = _WriteExtraToc;
- AH->PrintExtraTocPtr = _PrintExtraToc;
- AH->StartBlobsPtr = _StartBlobs;
- AH->StartBlobPtr = _StartBlob;
- AH->EndBlobPtr = _EndBlob;
- AH->EndBlobsPtr = _EndBlobs;
- AH->PrepParallelRestorePtr = _PrepParallelRestore;
- AH->ClonePtr = _Clone;
- AH->DeClonePtr = _DeClone;
- /* no parallel dump in the custom archive, only parallel restore */
- AH->WorkerJobDumpPtr = NULL;
- =====================================================================
- Found a 3 line (138 tokens) duplication in the following files:
- Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
- Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- =====================================================================
- Found a 3 line (138 tokens) duplication in the following files:
- Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
- Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- =====================================================================
- Found a 18 line (138 tokens) duplication in the following files:
- Starting at line 955 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
- Starting at line 1275 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
- Starting at line 1588 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
- InitFunctionCallInfoData(fcinfo, NULL, 7, collation, NULL, NULL);
- fcinfo.arg[0] = arg1;
- fcinfo.arg[1] = arg2;
- fcinfo.arg[2] = arg3;
- fcinfo.arg[3] = arg4;
- fcinfo.arg[4] = arg5;
- fcinfo.arg[5] = arg6;
- fcinfo.arg[6] = arg7;
- fcinfo.argnull[0] = false;
- fcinfo.argnull[1] = false;
- fcinfo.argnull[2] = false;
- fcinfo.argnull[3] = false;
- fcinfo.argnull[4] = false;
- fcinfo.argnull[5] = false;
- fcinfo.argnull[6] = false;
- result = (*func) (&fcinfo);
- =====================================================================
- Found a 29 line (138 tokens) duplication in the following files:
- Starting at line 1584 of /home/shackle/pggit/postgresql/src/backend/utils/adt/formatting.c
- Starting at line 1706 of /home/shackle/pggit/postgresql/src/backend/utils/adt/formatting.c
- Starting at line 1829 of /home/shackle/pggit/postgresql/src/backend/utils/adt/formatting.c
- len_conv = icu_convert_case(u_strToLower, mylocale,
- &buff_conv, buff_uchar, len_uchar);
- icu_from_uchar(&result, buff_conv, len_conv);
- pfree(buff_uchar);
- }
- else
- #endif
- {
- if (pg_database_encoding_max_length() > 1)
- {
- wchar_t *workspace;
- size_t curr_char;
- size_t result_size;
- /* Overflow paranoia */
- if ((nbytes + 1) > (INT_MAX / sizeof(wchar_t)))
- ereport(ERROR,
- (errcode(ERRCODE_OUT_OF_MEMORY),
- errmsg("out of memory")));
- /* Output workspace cannot have more codes than input bytes */
- workspace = (wchar_t *) palloc((nbytes + 1) * sizeof(wchar_t));
- char2wchar(workspace, nbytes + 1, buff, nbytes, mylocale);
- for (curr_char = 0; workspace[curr_char] != 0; curr_char++)
- {
- #ifdef HAVE_LOCALE_T
- if (mylocale)
- =====================================================================
- Found a 38 line (138 tokens) duplication in the following files:
- Starting at line 770 of /home/shackle/pggit/postgresql/src/backend/utils/adt/orderedsetaggs.c
- Starting at line 894 of /home/shackle/pggit/postgresql/src/backend/utils/adt/orderedsetaggs.c
- false);
- result_datum = (Datum *) palloc(num_percentiles * sizeof(Datum));
- result_isnull = (bool *) palloc(num_percentiles * sizeof(bool));
- /*
- * Start by dealing with any nulls in the param array - those are sorted
- * to the front on row=0, so set the corresponding result indexes to null
- */
- for (i = 0; i < num_percentiles; i++)
- {
- int idx = pct_info[i].idx;
- if (pct_info[i].first_row > 0)
- break;
- result_datum[idx] = (Datum) 0;
- result_isnull[idx] = true;
- }
- /*
- * If there's anything left after doing the nulls, then grind the input
- * and extract the needed values
- */
- if (i < num_percentiles)
- {
- /* Finish the sort, or rescan if we already did */
- if (!osastate->sort_done)
- {
- tuplesort_performsort(osastate->sortstate);
- osastate->sort_done = true;
- }
- else
- tuplesort_rescan(osastate->sortstate);
- for (; i < num_percentiles; i++)
- {
- int64 target_row = pct_info[i].first_row;
- =====================================================================
- Found a 31 line (137 tokens) duplication in the following files:
- Starting at line 261 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/ecpglib/data.c
- Starting at line 535 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/ecpglib/data.c
- if (varcharsize * offset < size)
- {
- /* truncation */
- switch (ind_type)
- {
- case ECPGt_short:
- case ECPGt_unsigned_short:
- *((short *) (ind + ind_offset * act_tuple)) = size;
- break;
- case ECPGt_int:
- case ECPGt_unsigned_int:
- *((int *) (ind + ind_offset * act_tuple)) = size;
- break;
- case ECPGt_long:
- case ECPGt_unsigned_long:
- *((long *) (ind + ind_offset * act_tuple)) = size;
- break;
- #ifdef HAVE_LONG_LONG_INT
- case ECPGt_long_long:
- case ECPGt_unsigned_long_long:
- *((long long int *) (ind + ind_offset * act_tuple)) = size;
- break;
- #endif /* HAVE_LONG_LONG_INT */
- default:
- break;
- }
- sqlca->sqlwarn[0] = sqlca->sqlwarn[1] = 'W';
- }
- }
- pval += size;
- }
- =====================================================================
- Found a 21 line (137 tokens) duplication in the following files:
- Starting at line 93 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-show.c
- Starting at line 64 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-quote.c
- { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set standard_conforming_strings to off", ECPGt_EOIT, ECPGt_EORT);
- #line 26 "show.pgc"
- if (sqlca.sqlwarn[0] == 'W') sqlprint();
- #line 26 "show.pgc"
- if (sqlca.sqlcode < 0) sqlprint();}
- #line 26 "show.pgc"
- { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "show standard_conforming_strings", ECPGt_EOIT,
- ECPGt_char,(var),(long)25,(long)1,(25)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
- #line 27 "show.pgc"
- if (sqlca.sqlwarn[0] == 'W') sqlprint();
- #line 27 "show.pgc"
- if (sqlca.sqlcode < 0) sqlprint();}
- #line 27 "show.pgc"
- printf("Var: Standard conforming strings: %s\n", var);
- =====================================================================
- Found a 25 line (136 tokens) duplication in the following files:
- Starting at line 38 of /home/shackle/pggit/postgresql/src/port/pgstrcasecmp.c
- Starting at line 71 of /home/shackle/pggit/postgresql/src/port/pgstrcasecmp.c
- for (;;)
- {
- unsigned char ch1 = (unsigned char) *s1++;
- unsigned char ch2 = (unsigned char) *s2++;
- if (ch1 != ch2)
- {
- if (ch1 >= 'A' && ch1 <= 'Z')
- ch1 += 'a' - 'A';
- else if (IS_HIGHBIT_SET(ch1) && isupper(ch1))
- ch1 = tolower(ch1);
- if (ch2 >= 'A' && ch2 <= 'Z')
- ch2 += 'a' - 'A';
- else if (IS_HIGHBIT_SET(ch2) && isupper(ch2))
- ch2 = tolower(ch2);
- if (ch1 != ch2)
- return (int) ch1 - (int) ch2;
- }
- if (ch1 == 0)
- break;
- }
- return 0;
- }
- =====================================================================
- Found a 26 line (136 tokens) duplication in the following files:
- Starting at line 56 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/interval.c
- Starting at line 3452 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
- ParseISO8601Number(const char *str, char **endptr, int *ipart, double *fpart)
- {
- double val;
- if (!(isdigit((unsigned char) *str) || *str == '-' || *str == '.'))
- return DTERR_BAD_FORMAT;
- errno = 0;
- val = strtod(str, endptr);
- /* did we not see anything that looks like a double? */
- if (*endptr == str || errno != 0)
- return DTERR_BAD_FORMAT;
- /* watch out for overflow */
- if (val < INT_MIN || val > INT_MAX)
- return DTERR_FIELD_OVERFLOW;
- /* be very sure we truncate towards zero (cf dtrunc()) */
- if (val >= 0)
- *ipart = (int) floor(val);
- else
- *ipart = (int) -floor(-val);
- *fpart = val - *ipart;
- return 0;
- }
- /* copy&pasted from .../src/backend/utils/adt/datetime.c */
- static int
- ISO8601IntegerWidth(const char *fieldstart)
- =====================================================================
- Found a 23 line (136 tokens) duplication in the following files:
- Starting at line 116 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-fetch.c
- Starting at line 195 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-fetch.c
- { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 in C", ECPGt_EOIT,
- ECPGt_int,&(i),(long)1,(long)1,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_char,(str),(long)25,(long)1,(25)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
- #line 32 "fetch.pgc"
- if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
- #line 32 "fetch.pgc"
- if (sqlca.sqlwarn[0] == 'W') sqlprint();
- #line 32 "fetch.pgc"
- if (sqlca.sqlcode < 0) sqlprint();}
- #line 32 "fetch.pgc"
- printf("%d: %s\n", i, str);
- }
- /* exec sql whenever not found continue ; */
- #line 36 "fetch.pgc"
- { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "move backward 2 in C", ECPGt_EOIT, ECPGt_EORT);
- =====================================================================
- Found a 15 line (136 tokens) duplication in the following files:
- Starting at line 200 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 215 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 230 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 248 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 273 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 291 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch forward from $0",
- ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
- ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
- #line 70 "cursor.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 70 "cursor.pgc"
- printf("%d %s\n", id, t);
- strcpy(msg, "fetch");
- =====================================================================
- Found a 15 line (136 tokens) duplication in the following files:
- Starting at line 340 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 355 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 370 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 388 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 417 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 435 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch from $0",
- ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
- ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
- #line 111 "cursor.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 111 "cursor.pgc"
- printf("%d %s\n", id, t);
- strcpy(msg, "fetch");
- =====================================================================
- Found a 15 line (136 tokens) duplication in the following files:
- Starting at line 523 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 538 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 556 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 581 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 599 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch from $0",
- ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
- ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
- #line 161 "cursor.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 161 "cursor.pgc"
- printf("%d %s\n", id, t);
- strcpy(msg, "fetch 1 from");
- =====================================================================
- Found a 28 line (136 tokens) duplication in the following files:
- Starting at line 119 of /home/shackle/pggit/postgresql/src/backend/utils/adt/expandedrecord.c
- Starting at line 250 of /home/shackle/pggit/postgresql/src/backend/utils/adt/expandedrecord.c
- Starting at line 342 of /home/shackle/pggit/postgresql/src/backend/utils/adt/expandedrecord.c
- objcxt = AllocSetContextCreate(parentcontext,
- "expanded record",
- ALLOCSET_DEFAULT_SIZES);
- /*
- * Since we already know the number of fields in the tupdesc, we can
- * allocate the dvalues/dnulls arrays along with the record header. This
- * is useless if we never need those arrays, but it costs almost nothing,
- * and it will save a palloc cycle if we do need them.
- */
- erh = (ExpandedRecordHeader *)
- MemoryContextAlloc(objcxt, MAXALIGN(sizeof(ExpandedRecordHeader))
- + tupdesc->natts * (sizeof(Datum) + sizeof(bool)));
- /* Ensure all header fields are initialized to 0/null */
- memset(erh, 0, sizeof(ExpandedRecordHeader));
- EOH_init_header(&erh->hdr, &ER_methods, objcxt);
- erh->er_magic = ER_MAGIC;
- /* Set up dvalues/dnulls, with no valid contents as yet */
- chunk = (char *) erh + MAXALIGN(sizeof(ExpandedRecordHeader));
- erh->dvalues = (Datum *) chunk;
- erh->dnulls = (bool *) (chunk + tupdesc->natts * sizeof(Datum));
- erh->nfields = tupdesc->natts;
- /* Fill in composite-type identification info */
- erh->er_decltypeid = type_id;
- =====================================================================
- Found a 33 line (136 tokens) duplication in the following files:
- Starting at line 1263 of /home/shackle/pggit/postgresql/src/backend/utils/adt/ri_triggers.c
- Starting at line 1450 of /home/shackle/pggit/postgresql/src/backend/utils/adt/ri_triggers.c
- "%s %s = NULL",
- querysep, attname);
- sprintf(paramname, "$%d", i + 1);
- ri_GenerateQual(&qualbuf, qualsep,
- paramname, pk_type,
- riinfo->pf_eq_oprs[i],
- attname, fk_type);
- querysep = ",";
- qualsep = "AND";
- queryoids[i] = pk_type;
- }
- appendStringInfoString(&querybuf, qualbuf.data);
- /* Prepare and save the plan */
- qplan = ri_PlanCheck(querybuf.data, riinfo->nkeys, queryoids,
- &qkey, fk_rel, pk_rel, true);
- }
- /*
- * We have a plan now. Run it to update the existing references.
- */
- ri_PerformCheck(riinfo, &qkey, qplan,
- fk_rel, pk_rel,
- old_row, NULL,
- true, /* must detect new rows */
- SPI_OK_UPDATE);
- if (SPI_finish() != SPI_OK_FINISH)
- elog(ERROR, "SPI_finish failed");
- heap_close(fk_rel, RowExclusiveLock);
- return PointerGetDatum(NULL);
- =====================================================================
- Found a 15 line (136 tokens) duplication in the following files:
- Starting at line 605 of /home/shackle/pggit/postgresql/src/backend/bootstrap/bootstrap.c
- Starting at line 931 of /home/shackle/pggit/postgresql/src/backend/bootstrap/bootstrap.c
- rel = heap_open(TypeRelationId, NoLock);
- scan = heap_beginscan_catalog(rel, 0, NULL);
- i = 0;
- while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL)
- ++i;
- heap_endscan(scan);
- app = Typ = ALLOC(struct typmap *, i + 1);
- while (i-- > 0)
- *app++ = ALLOC(struct typmap, 1);
- *app = NULL;
- scan = heap_beginscan_catalog(rel, 0, NULL);
- app = Typ;
- while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL)
- {
- (*app)->am_oid = ((Form_pg_type) GETSTRUCT(tup))->oid;
- =====================================================================
- Found a 29 line (135 tokens) duplication in the following files:
- Starting at line 810 of /home/shackle/pggit/postgresql/contrib/hstore/hstore_io.c
- Starting at line 328 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
- Starting at line 675 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
- ncolumns = tupdesc->natts;
- /*
- * We arrange to look up the needed I/O info just once per series of
- * calls, assuming the record type doesn't change underneath us.
- */
- my_extra = (RecordIOData *) fcinfo->flinfo->fn_extra;
- if (my_extra == NULL ||
- my_extra->ncolumns != ncolumns)
- {
- fcinfo->flinfo->fn_extra =
- MemoryContextAlloc(fcinfo->flinfo->fn_mcxt,
- offsetof(RecordIOData, columns) +
- ncolumns * sizeof(ColumnIOData));
- my_extra = (RecordIOData *) fcinfo->flinfo->fn_extra;
- my_extra->record_type = InvalidOid;
- my_extra->record_typmod = 0;
- }
- if (my_extra->record_type != tupType ||
- my_extra->record_typmod != tupTypmod)
- {
- MemSet(my_extra, 0,
- offsetof(RecordIOData, columns) +
- ncolumns * sizeof(ColumnIOData));
- my_extra->record_type = tupType;
- my_extra->record_typmod = tupTypmod;
- my_extra->ncolumns = ncolumns;
- }
- =====================================================================
- Found a 3 line (135 tokens) duplication in the following files:
- Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
- Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- =====================================================================
- Found a 3 line (135 tokens) duplication in the following files:
- Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
- Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- =====================================================================
- Found a 30 line (135 tokens) duplication in the following files:
- Starting at line 785 of /home/shackle/pggit/postgresql/src/backend/regex/regexec.c
- Starting at line 863 of /home/shackle/pggit/postgresql/src/backend/regex/regexec.c
- mid = longest(v, d, begin, end, (int *) NULL);
- NOERR();
- if (mid == NULL)
- return REG_NOMATCH;
- MDEBUG(("tentative midpoint %ld\n", LOFF(mid)));
- /* iterate until satisfaction or failure */
- for (;;)
- {
- /* try this midpoint on for size */
- if (longest(v, d2, mid, end, (int *) NULL) == end)
- {
- er = cdissect(v, t->left, begin, mid);
- if (er == REG_OKAY)
- {
- er = cdissect(v, t->right, mid, end);
- if (er == REG_OKAY)
- {
- /* satisfaction */
- MDEBUG(("successful\n"));
- return REG_OKAY;
- }
- }
- if (er != REG_NOMATCH)
- return er;
- }
- NOERR();
- /* that midpoint didn't work, find a new one */
- if (mid == begin)
- =====================================================================
- Found a 38 line (135 tokens) duplication in the following files:
- Starting at line 4745 of /home/shackle/pggit/postgresql/src/backend/postmaster/pgstat.c
- Starting at line 4880 of /home/shackle/pggit/postgresql/src/backend/postmaster/pgstat.c
- rc = fwrite(dbentry, offsetof(PgStat_StatDBEntry, tables), 1, fpout);
- (void) rc; /* we'll check for error with ferror */
- }
- /*
- * No more output to be done. Close the temp file and replace the old
- * pgstat.stat with it. The ferror() check replaces testing for error
- * after each individual fputc or fwrite above.
- */
- fputc('E', fpout);
- if (ferror(fpout))
- {
- ereport(LOG,
- (errcode_for_file_access(),
- errmsg("could not write temporary statistics file \"%s\": %m",
- tmpfile)));
- FreeFile(fpout);
- unlink(tmpfile);
- }
- else if (FreeFile(fpout) < 0)
- {
- ereport(LOG,
- (errcode_for_file_access(),
- errmsg("could not close temporary statistics file \"%s\": %m",
- tmpfile)));
- unlink(tmpfile);
- }
- else if (rename(tmpfile, statfile) < 0)
- {
- ereport(LOG,
- (errcode_for_file_access(),
- errmsg("could not rename temporary statistics file \"%s\" to \"%s\": %m",
- tmpfile, statfile)));
- unlink(tmpfile);
- }
- if (permanent)
- =====================================================================
- Found a 39 line (135 tokens) duplication in the following files:
- Starting at line 263 of /home/shackle/pggit/postgresql/src/backend/utils/time/tqual.c
- Starting at line 848 of /home/shackle/pggit/postgresql/src/backend/utils/time/tqual.c
- else if (TransactionIdDidCommit(HeapTupleHeaderGetRawXmin(tuple)))
- SetHintBits(tuple, buffer, HEAP_XMIN_COMMITTED,
- HeapTupleHeaderGetRawXmin(tuple));
- else
- {
- /* it must have aborted or crashed */
- SetHintBits(tuple, buffer, HEAP_XMIN_INVALID,
- InvalidTransactionId);
- return false;
- }
- }
- /* by here, the inserting transaction has committed */
- if (tuple->t_infomask & HEAP_XMAX_INVALID) /* xid invalid or aborted */
- return true;
- if (tuple->t_infomask & HEAP_XMAX_COMMITTED)
- {
- if (HEAP_XMAX_IS_LOCKED_ONLY(tuple->t_infomask))
- return true;
- return false; /* updated by other */
- }
- if (tuple->t_infomask & HEAP_XMAX_IS_MULTI)
- {
- TransactionId xmax;
- if (HEAP_XMAX_IS_LOCKED_ONLY(tuple->t_infomask))
- return true;
- xmax = HeapTupleGetUpdateXid(tuple);
- /* not LOCKED_ONLY, so it has to have an xmax */
- Assert(TransactionIdIsValid(xmax));
- if (TransactionIdIsCurrentTransactionId(xmax))
- return false;
- if (TransactionIdIsInProgress(xmax))
- =====================================================================
- Found a 26 line (134 tokens) duplication in the following files:
- Starting at line 78 of /home/shackle/pggit/postgresql/src/test/modules/test_rls_hooks/test_rls_hooks.c
- Starting at line 143 of /home/shackle/pggit/postgresql/src/test/modules/test_rls_hooks/test_rls_hooks.c
- if (strcmp(RelationGetRelationName(relation), "rls_test_permissive")
- && strcmp(RelationGetRelationName(relation), "rls_test_both"))
- return NIL;
- qual_pstate = make_parsestate(NULL);
- rte = addRangeTableEntryForRelation(qual_pstate, relation, AccessShareLock,
- NULL, false, false);
- addRTEtoQuery(qual_pstate, rte, false, true, true);
- role = ObjectIdGetDatum(ACL_ID_PUBLIC);
- policy->policy_name = pstrdup("extension policy");
- policy->polcmd = '*';
- policy->roles = construct_array(&role, 1, OIDOID, sizeof(Oid), true, 'i');
- /*
- * policy->qual = (Expr *) makeConst(BOOLOID, -1, InvalidOid,
- * sizeof(bool), BoolGetDatum(true), false, true);
- */
- n = makeFuncCall(list_make2(makeString("pg_catalog"),
- makeString("current_user")), NIL, 0);
- c = makeNode(ColumnRef);
- c->fields = list_make1(makeString("username"));
- =====================================================================
- Found a 4 line (134 tokens) duplication in the following files:
- Starting at line 30 of /home/shackle/pggit/postgresql/src/common/base64.c
- Starting at line 3562 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
- Starting at line 114 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 206 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 40 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
- static const int8 b64lookup[128] = {
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
- =====================================================================
- Found a 16 line (134 tokens) duplication in the following files:
- Starting at line 2020 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
- Starting at line 2085 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
- return InvalidOid;
- if (IsA(expr, FuncExpr))
- args = ((FuncExpr *) expr)->args;
- else if (IsA(expr, OpExpr))
- args = ((OpExpr *) expr)->args;
- else if (IsA(expr, DistinctExpr))
- args = ((DistinctExpr *) expr)->args;
- else if (IsA(expr, ScalarArrayOpExpr))
- args = ((ScalarArrayOpExpr *) expr)->args;
- else if (IsA(expr, NullIfExpr))
- args = ((NullIfExpr *) expr)->args;
- else if (IsA(expr, WindowFunc))
- args = ((WindowFunc *) expr)->args;
- else
- return InvalidOid;
- =====================================================================
- Found a 28 line (134 tokens) duplication in the following files:
- Starting at line 518 of /home/shackle/pggit/postgresql/src/backend/access/nbtree/nbtpage.c
- Starting at line 606 of /home/shackle/pggit/postgresql/src/backend/access/nbtree/nbtpage.c
- rel->rd_amcache = NULL;
- metabuf = _bt_getbuf(rel, BTREE_METAPAGE, BT_READ);
- metapg = BufferGetPage(metabuf);
- metaopaque = (BTPageOpaque) PageGetSpecialPointer(metapg);
- metad = BTPageGetMeta(metapg);
- if (!P_ISMETA(metaopaque) ||
- metad->btm_magic != BTREE_MAGIC)
- ereport(ERROR,
- (errcode(ERRCODE_INDEX_CORRUPTED),
- errmsg("index \"%s\" is not a btree",
- RelationGetRelationName(rel))));
- if (metad->btm_version < BTREE_MIN_VERSION ||
- metad->btm_version > BTREE_VERSION)
- ereport(ERROR,
- (errcode(ERRCODE_INDEX_CORRUPTED),
- errmsg("version mismatch in index \"%s\": file version %d, "
- "current version %d, minimal supported version %d",
- RelationGetRelationName(rel),
- metad->btm_version, BTREE_VERSION, BTREE_MIN_VERSION)));
- /* if no root page initialized yet, fail */
- if (metad->btm_root == P_NONE)
- {
- _bt_relbuf(rel, metabuf);
- return InvalidBuffer;
- =====================================================================
- Found a 15 line (133 tokens) duplication in the following files:
- Starting at line 678 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 693 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 708 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 726 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 751 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 769 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch from $0",
- ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
- ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
- #line 209 "cursor.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 209 "cursor.pgc"
- printf("%d %s\n", id, t);
- strcpy(msg, "fetch");
- =====================================================================
- Found a 31 line (133 tokens) duplication in the following files:
- Starting at line 1284 of /home/shackle/pggit/postgresql/src/backend/executor/nodeIndexscan.c
- Starting at line 1533 of /home/shackle/pggit/postgresql/src/backend/executor/nodeIndexscan.c
- Assert(rightop != NULL);
- if (IsA(rightop, Const))
- {
- /* OK, simple constant comparison value */
- scanvalue = ((Const *) rightop)->constvalue;
- if (((Const *) rightop)->constisnull)
- flags |= SK_ISNULL;
- }
- else
- {
- /* Need to treat this one as a runtime key */
- if (n_runtime_keys >= max_runtime_keys)
- {
- if (max_runtime_keys == 0)
- {
- max_runtime_keys = 8;
- runtime_keys = (IndexRuntimeKeyInfo *)
- palloc(max_runtime_keys * sizeof(IndexRuntimeKeyInfo));
- }
- else
- {
- max_runtime_keys *= 2;
- runtime_keys = (IndexRuntimeKeyInfo *)
- repalloc(runtime_keys, max_runtime_keys * sizeof(IndexRuntimeKeyInfo));
- }
- }
- runtime_keys[n_runtime_keys].scan_key = this_scan_key;
- runtime_keys[n_runtime_keys].key_expr =
- ExecInitExpr(rightop, planstate);
- runtime_keys[n_runtime_keys].key_toastable =
- =====================================================================
- Found a 40 line (133 tokens) duplication in the following files:
- Starting at line 6344 of /home/shackle/pggit/postgresql/src/backend/utils/adt/numeric.c
- Starting at line 6463 of /home/shackle/pggit/postgresql/src/backend/utils/adt/numeric.c
- alloc_var(var, 20 / DEC_DIGITS);
- if (val < 0)
- {
- var->sign = NUMERIC_NEG;
- uval = -val;
- }
- else
- {
- var->sign = NUMERIC_POS;
- uval = val;
- }
- var->dscale = 0;
- if (val == 0)
- {
- var->ndigits = 0;
- var->weight = 0;
- return;
- }
- ptr = var->digits + var->ndigits;
- ndigits = 0;
- do
- {
- ptr--;
- ndigits++;
- newuval = uval / NBASE;
- *ptr = uval - newuval * NBASE;
- uval = newuval;
- } while (uval);
- var->digits = ptr;
- var->ndigits = ndigits;
- var->weight = ndigits - 1;
- }
- #ifdef HAVE_INT128
- /*
- * Convert numeric to int128, rounding if needed.
- *
- * If overflow, return false (no error is raised). Return true if okay.
- */
- static bool
- =====================================================================
- Found a 26 line (133 tokens) duplication in the following files:
- Starting at line 1467 of /home/shackle/pggit/postgresql/src/backend/commands/event_trigger.c
- Starting at line 2019 of /home/shackle/pggit/postgresql/src/backend/commands/event_trigger.c
- "pg_event_trigger_dropped_objects()")));
- /* check to see if caller supports us returning a tuplestore */
- if (rsinfo == NULL || !IsA(rsinfo, ReturnSetInfo))
- ereport(ERROR,
- (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("set-valued function called in context that cannot accept a set")));
- if (!(rsinfo->allowedModes & SFRM_Materialize))
- ereport(ERROR,
- (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("materialize mode required, but it is not allowed in this context")));
- /* Build a tuple descriptor for our result type */
- if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
- elog(ERROR, "return type must be a row type");
- /* Build tuplestore to hold the result rows */
- per_query_ctx = rsinfo->econtext->ecxt_per_query_memory;
- oldcontext = MemoryContextSwitchTo(per_query_ctx);
- tupstore = tuplestore_begin_heap(true, false, work_mem);
- rsinfo->returnMode = SFRM_Materialize;
- rsinfo->setResult = tupstore;
- rsinfo->setDesc = tupdesc;
- MemoryContextSwitchTo(oldcontext);
- =====================================================================
- Found a 23 line (133 tokens) duplication in the following files:
- Starting at line 56 of /home/shackle/pggit/postgresql/src/backend/access/brin/brin_validate.c
- Starting at line 56 of /home/shackle/pggit/postgresql/src/backend/access/nbtree/nbtvalidate.c
- Starting at line 59 of /home/shackle/pggit/postgresql/src/backend/access/spgist/spgvalidate.c
- Starting at line 61 of /home/shackle/pggit/postgresql/src/backend/access/hash/hashvalidate.c
- ListCell *lc;
- /* Fetch opclass information */
- classtup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclassoid));
- if (!HeapTupleIsValid(classtup))
- elog(ERROR, "cache lookup failed for operator class %u", opclassoid);
- classform = (Form_pg_opclass) GETSTRUCT(classtup);
- opfamilyoid = classform->opcfamily;
- opcintype = classform->opcintype;
- opclassname = NameStr(classform->opcname);
- /* Fetch opfamily information */
- familytup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfamilyoid));
- if (!HeapTupleIsValid(familytup))
- elog(ERROR, "cache lookup failed for operator family %u", opfamilyoid);
- familyform = (Form_pg_opfamily) GETSTRUCT(familytup);
- opfamilyname = NameStr(familyform->opfname);
- /* Fetch all operators and support functions of the opfamily */
- oprlist = SearchSysCacheList1(AMOPSTRATEGY, ObjectIdGetDatum(opfamilyoid));
- proclist = SearchSysCacheList1(AMPROCNUM, ObjectIdGetDatum(opfamilyoid));
- =====================================================================
- Found a 34 line (133 tokens) duplication in the following files:
- Starting at line 194 of /home/shackle/pggit/postgresql/src/backend/replication/slotfuncs.c
- Starting at line 1105 of /home/shackle/pggit/postgresql/src/backend/replication/logical/launcher.c
- Starting at line 3227 of /home/shackle/pggit/postgresql/src/backend/replication/walsender.c
- int slotno;
- /* check to see if caller supports us returning a tuplestore */
- if (rsinfo == NULL || !IsA(rsinfo, ReturnSetInfo))
- ereport(ERROR,
- (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("set-valued function called in context that cannot accept a set")));
- if (!(rsinfo->allowedModes & SFRM_Materialize))
- ereport(ERROR,
- (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("materialize mode required, but it is not " \
- "allowed in this context")));
- /* Build a tuple descriptor for our result type */
- if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
- elog(ERROR, "return type must be a row type");
- /*
- * We don't require any special permission to see this function's data
- * because nothing should be sensitive. The most critical being the slot
- * name, which shouldn't contain anything particularly sensitive.
- */
- per_query_ctx = rsinfo->econtext->ecxt_per_query_memory;
- oldcontext = MemoryContextSwitchTo(per_query_ctx);
- tupstore = tuplestore_begin_heap(true, false, work_mem);
- rsinfo->returnMode = SFRM_Materialize;
- rsinfo->setResult = tupstore;
- rsinfo->setDesc = tupdesc;
- MemoryContextSwitchTo(oldcontext);
- LWLockAcquire(ReplicationSlotControlLock, LW_SHARED);
- =====================================================================
- Found a 39 line (132 tokens) duplication in the following files:
- Starting at line 122 of /home/shackle/pggit/postgresql/src/bin/scripts/reindexdb.c
- Starting at line 102 of /home/shackle/pggit/postgresql/src/bin/scripts/clusterdb.c
- simple_string_list_append(&indexes, optarg);
- break;
- case 'v':
- verbose = true;
- break;
- case 2:
- maintenance_db = pg_strdup(optarg);
- break;
- default:
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
- exit(1);
- }
- }
- /*
- * Non-option argument specifies database name as long as it wasn't
- * already specified with -d / --dbname
- */
- if (optind < argc && dbname == NULL)
- {
- dbname = argv[optind];
- optind++;
- }
- if (optind < argc)
- {
- fprintf(stderr, _("%s: too many command-line arguments (first is \"%s\")\n"),
- progname, argv[optind]);
- fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
- exit(1);
- }
- setup_cancel_handler();
- if (alldb)
- {
- if (dbname)
- {
- fprintf(stderr, _("%s: cannot reindex all databases and a specific one at the same time\n"), progname);
- =====================================================================
- Found a 3 line (132 tokens) duplication in the following files:
- Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
- Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- =====================================================================
- Found a 3 line (132 tokens) duplication in the following files:
- Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
- Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- =====================================================================
- Found a 21 line (132 tokens) duplication in the following files:
- Starting at line 172 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-array_of_struct.c
- Starting at line 176 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-pointer_to_struct.c
- ECPGt_short,&(inds->phone_ind),(long)1,(long)10,sizeof( struct ind ), ECPGt_EORT);
- #line 56 "array_of_struct.pgc"
- if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint();
- #line 56 "array_of_struct.pgc"
- if (sqlca.sqlwarn[0] == 'W') sqlprint();
- #line 56 "array_of_struct.pgc"
- if (sqlca.sqlcode < 0) sqlprint();}
- #line 56 "array_of_struct.pgc"
- printf("custs1:\n");
- for (r = 0; r < 2; r++)
- {
- printf( "name - %s\n", custs1[r].name.arr );
- printf( "phone - %d\n", custs1[r].phone );
- }
- { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select * from customers limit 2", ECPGt_EOIT,
- ECPGt_varchar,&(custs2->name),(long)50,(long)10,sizeof( customer2 ),
- =====================================================================
- Found a 26 line (132 tokens) duplication in the following files:
- Starting at line 97 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/utf8_and_iso8859/utf8_and_iso8859.c
- Starting at line 78 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/utf8_and_win/utf8_and_win.c
- iso8859_to_utf8(PG_FUNCTION_ARGS)
- {
- int encoding = PG_GETARG_INT32(0);
- unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
- unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
- int len = PG_GETARG_INT32(4);
- int i;
- CHECK_ENCODING_CONVERSION_ARGS(-1, PG_UTF8);
- for (i = 0; i < lengthof(maps); i++)
- {
- if (encoding == maps[i].encoding)
- {
- LocalToUtf(src, len, dest,
- maps[i].map1,
- NULL, 0,
- NULL,
- encoding);
- PG_RETURN_VOID();
- }
- }
- ereport(ERROR,
- (errcode(ERRCODE_INTERNAL_ERROR),
- errmsg("unexpected encoding ID %d for ISO 8859 character sets",
- =====================================================================
- Found a 26 line (132 tokens) duplication in the following files:
- Starting at line 129 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/utf8_and_iso8859/utf8_and_iso8859.c
- Starting at line 110 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/utf8_and_win/utf8_and_win.c
- utf8_to_iso8859(PG_FUNCTION_ARGS)
- {
- int encoding = PG_GETARG_INT32(1);
- unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
- unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
- int len = PG_GETARG_INT32(4);
- int i;
- CHECK_ENCODING_CONVERSION_ARGS(PG_UTF8, -1);
- for (i = 0; i < lengthof(maps); i++)
- {
- if (encoding == maps[i].encoding)
- {
- UtfToLocal(src, len, dest,
- maps[i].map2,
- NULL, 0,
- NULL,
- encoding);
- PG_RETURN_VOID();
- }
- }
- ereport(ERROR,
- (errcode(ERRCODE_INTERNAL_ERROR),
- errmsg("unexpected encoding ID %d for ISO 8859 character sets",
- =====================================================================
- Found a 10 line (132 tokens) duplication in the following files:
- Starting at line 47 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/latin2_and_win1250/latin2_and_win1250.c
- Starting at line 67 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/latin2_and_win1250/latin2_and_win1250.c
- 0xB8, 0xB1, 0xBA, 0x00, 0xA5, 0xBD, 0xB5, 0xBF,
- 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
- 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF,
- 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7,
- 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF,
- 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7,
- 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF,
- 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7,
- 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF
- };
- =====================================================================
- Found a 27 line (132 tokens) duplication in the following files:
- Starting at line 3821 of /home/shackle/pggit/postgresql/src/backend/utils/adt/timestamp.c
- Starting at line 3955 of /home/shackle/pggit/postgresql/src/backend/utils/adt/timestamp.c
- if (timestamp2tm(timestamp, NULL, tm, &fsec, NULL, NULL) != 0)
- ereport(ERROR,
- (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
- errmsg("timestamp out of range")));
- switch (val)
- {
- case DTK_WEEK:
- {
- int woy;
- woy = date2isoweek(tm->tm_year, tm->tm_mon, tm->tm_mday);
- /*
- * If it is week 52/53 and the month is January, then the
- * week must belong to the previous year. Also, some
- * December dates belong to the next year.
- */
- if (woy >= 52 && tm->tm_mon == 1)
- --tm->tm_year;
- if (woy <= 1 && tm->tm_mon == MONTHS_PER_YEAR)
- ++tm->tm_year;
- isoweek2date(woy, &(tm->tm_year), &(tm->tm_mon), &(tm->tm_mday));
- tm->tm_hour = 0;
- tm->tm_min = 0;
- tm->tm_sec = 0;
- fsec = 0;
- =====================================================================
- Found a 27 line (132 tokens) duplication in the following files:
- Starting at line 2224 of /home/shackle/pggit/postgresql/src/backend/commands/extension.c
- Starting at line 192 of /home/shackle/pggit/postgresql/src/backend/access/transam/xlogfuncs.c
- check_valid_extension_name(NameStr(*extname));
- /* check to see if caller supports us returning a tuplestore */
- if (rsinfo == NULL || !IsA(rsinfo, ReturnSetInfo))
- ereport(ERROR,
- (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("set-valued function called in context that cannot accept a set")));
- if (!(rsinfo->allowedModes & SFRM_Materialize))
- ereport(ERROR,
- (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("materialize mode required, but it is not " \
- "allowed in this context")));
- /* Build a tuple descriptor for our result type */
- if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
- elog(ERROR, "return type must be a row type");
- /* Build tuplestore to hold the result rows */
- per_query_ctx = rsinfo->econtext->ecxt_per_query_memory;
- oldcontext = MemoryContextSwitchTo(per_query_ctx);
- tupstore = tuplestore_begin_heap(true, false, work_mem);
- rsinfo->returnMode = SFRM_Materialize;
- rsinfo->setResult = tupstore;
- rsinfo->setDesc = tupdesc;
- MemoryContextSwitchTo(oldcontext);
- =====================================================================
- Found a 23 line (131 tokens) duplication in the following files:
- Starting at line 123 of /home/shackle/pggit/postgresql/contrib/btree_gist/btree_enum.c
- Starting at line 137 of /home/shackle/pggit/postgresql/contrib/btree_gist/btree_oid.c
- gbt_enum_consistent(PG_FUNCTION_ARGS)
- {
- GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
- Oid query = PG_GETARG_OID(1);
- StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
- /* Oid subtype = PG_GETARG_OID(3); */
- bool *recheck = (bool *) PG_GETARG_POINTER(4);
- oidKEY *kkk = (oidKEY *) DatumGetPointer(entry->key);
- GBT_NUMKEY_R key;
- /* All cases served by this function are exact */
- *recheck = false;
- key.lower = (GBT_NUMKEY *) &kkk->lower;
- key.upper = (GBT_NUMKEY *) &kkk->upper;
- PG_RETURN_BOOL(
- gbt_num_consistent(&key, (void *) &query, &strategy, GIST_LEAF(entry), &tinfo, fcinfo->flinfo)
- );
- }
- Datum
- =====================================================================
- Found a 26 line (131 tokens) duplication in the following files:
- Starting at line 50 of /home/shackle/pggit/postgresql/src/common/base64.c
- Starting at line 221 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- char *p;
- const char *s,
- *end = src + len;
- int pos = 2;
- uint32 buf = 0;
- s = src;
- p = dst;
- while (s < end)
- {
- buf |= (unsigned char) *s << (pos << 3);
- pos--;
- s++;
- /* write it out */
- if (pos < 0)
- {
- *p++ = _base64[(buf >> 18) & 0x3f];
- *p++ = _base64[(buf >> 12) & 0x3f];
- *p++ = _base64[(buf >> 6) & 0x3f];
- *p++ = _base64[buf & 0x3f];
- pos = 2;
- buf = 0;
- }
- =====================================================================
- Found a 15 line (131 tokens) duplication in the following files:
- Starting at line 216 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 356 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 524 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 694 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
- ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
- #line 74 "cursor.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 74 "cursor.pgc"
- printf("%d %s\n", id, t);
- strcpy(msg, "fetch 1 from");
- { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch 1 from $0",
- =====================================================================
- Found a 15 line (131 tokens) duplication in the following files:
- Starting at line 292 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 436 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 600 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 770 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
- ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
- #line 95 "cursor.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 95 "cursor.pgc"
- printf("%d %s\n", id, t);
- strcpy(msg, "close");
- { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "close $0",
- =====================================================================
- Found a 15 line (131 tokens) duplication in the following files:
- Starting at line 341 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 679 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
- ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
- #line 111 "cursor.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 111 "cursor.pgc"
- printf("%d %s\n", id, t);
- strcpy(msg, "fetch");
- { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0",
- =====================================================================
- Found a 15 line (131 tokens) duplication in the following files:
- Starting at line 389 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 557 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 727 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
- ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
- #line 124 "cursor.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 124 "cursor.pgc"
- printf("%d %s\n", id, t);
- strcpy(msg, "move");
- { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "move absolute 0 $0",
- =====================================================================
- Found a 26 line (131 tokens) duplication in the following files:
- Starting at line 552 of /home/shackle/pggit/postgresql/src/backend/utils/adt/pgstatfuncs.c
- Starting at line 1891 of /home/shackle/pggit/postgresql/src/backend/commands/extension.c
- Starting at line 2000 of /home/shackle/pggit/postgresql/src/backend/commands/extension.c
- Starting at line 2224 of /home/shackle/pggit/postgresql/src/backend/commands/extension.c
- Starting at line 192 of /home/shackle/pggit/postgresql/src/backend/access/transam/xlogfuncs.c
- Starting at line 194 of /home/shackle/pggit/postgresql/src/backend/replication/slotfuncs.c
- Starting at line 1105 of /home/shackle/pggit/postgresql/src/backend/replication/logical/launcher.c
- Starting at line 3227 of /home/shackle/pggit/postgresql/src/backend/replication/walsender.c
- MemoryContext oldcontext;
- /* check to see if caller supports us returning a tuplestore */
- if (rsinfo == NULL || !IsA(rsinfo, ReturnSetInfo))
- ereport(ERROR,
- (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("set-valued function called in context that cannot accept a set")));
- if (!(rsinfo->allowedModes & SFRM_Materialize))
- ereport(ERROR,
- (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("materialize mode required, but it is not " \
- "allowed in this context")));
- /* Build a tuple descriptor for our result type */
- if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
- elog(ERROR, "return type must be a row type");
- per_query_ctx = rsinfo->econtext->ecxt_per_query_memory;
- oldcontext = MemoryContextSwitchTo(per_query_ctx);
- tupstore = tuplestore_begin_heap(true, false, work_mem);
- rsinfo->returnMode = SFRM_Materialize;
- rsinfo->setResult = tupstore;
- rsinfo->setDesc = tupdesc;
- MemoryContextSwitchTo(oldcontext);
- =====================================================================
- Found a 28 line (131 tokens) duplication in the following files:
- Starting at line 4034 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
- Starting at line 4066 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
- *str++ = '/';
- str = pg_ltostr_zeropad(str,
- (tm->tm_year > 0) ? tm->tm_year : -(tm->tm_year - 1), 4);
- *str++ = ' ';
- str = pg_ltostr_zeropad(str, tm->tm_hour, 2);
- *str++ = ':';
- str = pg_ltostr_zeropad(str, tm->tm_min, 2);
- *str++ = ':';
- str = AppendTimestampSeconds(str, tm, fsec);
- /*
- * Note: the uses of %.*s in this function would be risky if the
- * timezone names ever contain non-ASCII characters. However, all
- * TZ abbreviations in the IANA database are plain ASCII.
- */
- if (print_tz)
- {
- if (tzn)
- {
- sprintf(str, " %.*s", MAXTZLEN, tzn);
- str += strlen(str);
- }
- else
- str = EncodeTimezone(str, tz, style);
- }
- break;
- case USE_GERMAN_DATES:
- =====================================================================
- Found a 34 line (131 tokens) duplication in the following files:
- Starting at line 3240 of /home/shackle/pggit/postgresql/src/backend/commands/typecmds.c
- Starting at line 3322 of /home/shackle/pggit/postgresql/src/backend/commands/typecmds.c
- if (stmt->renameType == OBJECT_DOMAIN && typTup->typtype != TYPTYPE_DOMAIN)
- ereport(ERROR,
- (errcode(ERRCODE_WRONG_OBJECT_TYPE),
- errmsg("%s is not a domain",
- format_type_be(typeOid))));
- /*
- * If it's a composite type, we need to check that it really is a
- * free-standing composite type, and not a table's rowtype. We want people
- * to use ALTER TABLE not ALTER TYPE for that case.
- */
- if (typTup->typtype == TYPTYPE_COMPOSITE &&
- get_rel_relkind(typTup->typrelid) != RELKIND_COMPOSITE_TYPE)
- ereport(ERROR,
- (errcode(ERRCODE_WRONG_OBJECT_TYPE),
- errmsg("%s is a table's row type",
- format_type_be(typeOid)),
- errhint("Use ALTER TABLE instead.")));
- /* don't allow direct alteration of array types, either */
- if (OidIsValid(typTup->typelem) &&
- get_array_type(typTup->typelem) == typeOid)
- ereport(ERROR,
- (errcode(ERRCODE_WRONG_OBJECT_TYPE),
- errmsg("cannot alter array type %s",
- format_type_be(typeOid)),
- errhint("You can alter type %s, which will alter the array type as well.",
- format_type_be(typTup->typelem))));
- /*
- * If type is composite we need to rename associated pg_class entry too.
- * RenameRelationInternal will call RenameTypeInternal automatically.
- */
- if (typTup->typtype == TYPTYPE_COMPOSITE)
- =====================================================================
- Found a 5 line (130 tokens) duplication in the following files:
- Starting at line 74 of /home/shackle/pggit/postgresql/contrib/pgcrypto/crypt-des.c
- Starting at line 334 of /home/shackle/pggit/postgresql/src/port/crypt.c
- static uint8 IP[64] = {
- 58, 50, 42, 34, 26, 18, 10, 2, 60, 52, 44, 36, 28, 20, 12, 4,
- 62, 54, 46, 38, 30, 22, 14, 6, 64, 56, 48, 40, 32, 24, 16, 8,
- 57, 49, 41, 33, 25, 17, 9, 1, 59, 51, 43, 35, 27, 19, 11, 3,
- 61, 53, 45, 37, 29, 21, 13, 5, 63, 55, 47, 39, 31, 23, 15, 7
- =====================================================================
- Found a 14 line (130 tokens) duplication in the following files:
- Starting at line 201 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 356 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 371 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 389 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 418 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 436 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 509 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 524 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 539 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 557 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 582 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 600 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
- ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
- #line 70 "cursor.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 70 "cursor.pgc"
- printf("%d %s\n", id, t);
- strcpy(msg, "fetch");
- =====================================================================
- Found a 14 line (130 tokens) duplication in the following files:
- Starting at line 216 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 231 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 249 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 274 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 292 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 341 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
- ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
- #line 74 "cursor.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 74 "cursor.pgc"
- printf("%d %s\n", id, t);
- strcpy(msg, "fetch 1 from");
- =====================================================================
- Found a 5 line (129 tokens) duplication in the following files:
- Starting at line 31 of /home/shackle/pggit/postgresql/contrib/ltree/_ltree_gist.c
- Starting at line 51 of /home/shackle/pggit/postgresql/contrib/pg_trgm/trgm_gist.c
- Starting at line 32 of /home/shackle/pggit/postgresql/contrib/intarray/_intbig_gist.c
- Starting at line 117 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
- Starting at line 82 of /home/shackle/pggit/postgresql/src/backend/utils/adt/tsgistidx.c
- 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
- 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
- 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
- 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
- 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
- =====================================================================
- Found a 5 line (129 tokens) duplication in the following files:
- Starting at line 35 of /home/shackle/pggit/postgresql/contrib/ltree/_ltree_gist.c
- Starting at line 47 of /home/shackle/pggit/postgresql/contrib/pg_trgm/trgm_gist.c
- Starting at line 28 of /home/shackle/pggit/postgresql/contrib/intarray/_intbig_gist.c
- Starting at line 113 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
- Starting at line 78 of /home/shackle/pggit/postgresql/src/backend/utils/adt/tsgistidx.c
- 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
- 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
- 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
- 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
- 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
- =====================================================================
- Found a 32 line (129 tokens) duplication in the following files:
- Starting at line 6947 of /home/shackle/pggit/postgresql/src/pl/plpgsql/src/pl_exec.c
- Starting at line 7056 of /home/shackle/pggit/postgresql/src/pl/plpgsql/src/pl_exec.c
- while (anum < td_natts &&
- TupleDescAttr(tupdesc, anum)->attisdropped)
- anum++; /* skip dropped column in tuple */
- if (anum < td_natts)
- {
- value = values[anum];
- isnull = nulls[anum];
- valtype = TupleDescAttr(tupdesc, anum)->atttypid;
- valtypmod = TupleDescAttr(tupdesc, anum)->atttypmod;
- anum++;
- }
- else
- {
- /* no source for destination column */
- value = (Datum) 0;
- isnull = true;
- valtype = UNKNOWNOID;
- valtypmod = -1;
- /* When source value is missing */
- if (strict_multiassignment_level)
- ereport(strict_multiassignment_level,
- (errcode(ERRCODE_DATATYPE_MISMATCH),
- errmsg("number of source and target fields in assignment do not match"),
- /* translator: %s represents a name of an extra check */
- errdetail("%s check of %s is active.",
- "strict_multi_assignment",
- strict_multiassignment_level == ERROR ? "extra_errors" :
- "extra_warnings"),
- errhint("Make sure the query returns the exact list of columns.")));
- }
- =====================================================================
- Found a 25 line (129 tokens) duplication in the following files:
- Starting at line 1361 of /home/shackle/pggit/postgresql/src/pl/plpython/plpy_typeio.c
- Starting at line 1501 of /home/shackle/pggit/postgresql/src/pl/plpython/plpy_typeio.c
- Assert(PyMapping_Check(mapping));
- /* Build tuple */
- values = palloc(sizeof(Datum) * desc->natts);
- nulls = palloc(sizeof(bool) * desc->natts);
- for (i = 0; i < desc->natts; ++i)
- {
- char *key;
- PyObject *volatile value;
- PLyObToDatum *att;
- Form_pg_attribute attr = TupleDescAttr(desc, i);
- if (attr->attisdropped)
- {
- values[i] = (Datum) 0;
- nulls[i] = true;
- continue;
- }
- key = NameStr(attr->attname);
- value = NULL;
- att = &arg->u.tuple.atts[i];
- PG_TRY();
- {
- value = PyMapping_GetItemString(mapping, key);
- =====================================================================
- Found a 3 line (129 tokens) duplication in the following files:
- Starting at line 31 of /home/shackle/pggit/postgresql/src/common/base64.c
- Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
- Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
- Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
- Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
- Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
- Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
- Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 207 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
- Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
- Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
- Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
- Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
- Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
- =====================================================================
- Found a 9 line (129 tokens) duplication in the following files:
- Starting at line 203 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-array.c
- Starting at line 298 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-array.c
- { 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 )",
- ECPGt_timestamp,&(ts),(long)1,(long)10,sizeof(timestamp),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_numeric,&(n),(long)1,(long)10,sizeof(numeric),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_date,&(d),(long)1,(long)10,sizeof(date),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_interval,&(in),(long)1,(long)10,sizeof(interval),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
- =====================================================================
- Found a 33 line (129 tokens) duplication in the following files:
- Starting at line 31 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/connect-test2.c
- Starting at line 30 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/connect-test3.c
- int
- main(void)
- {
- /* exec sql begin declare section */
- #line 17 "test2.pgc"
- char id [ 200 ] ;
- #line 18 "test2.pgc"
- char res [ 200 ] ;
- /* exec sql end declare section */
- #line 19 "test2.pgc"
- ECPGdebug(1, stderr);
- strcpy(id, "first");
- { ECPGconnect(__LINE__, 0, "ecpg2_regression" , NULL, NULL , id, 0); }
- #line 24 "test2.pgc"
- { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , "second", 0); }
- #line 25 "test2.pgc"
- /* this selects from "second" which was opened last */
- { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select current_database ( )", ECPGt_EOIT,
- ECPGt_char,(res),(long)200,(long)1,(200)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
- #line 28 "test2.pgc"
- { ECPGdo(__LINE__, 0, 1, "first", 0, ECPGst_normal, "select current_database ( )", ECPGt_EOIT,
- =====================================================================
- Found a 21 line (129 tokens) duplication in the following files:
- Starting at line 74 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/connect-test2.c
- Starting at line 52 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/connect-test3.c
- { ECPGsetconn(__LINE__, "first");}
- #line 32 "test2.pgc"
- { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select current_database ( )", ECPGt_EOIT,
- ECPGt_char,(res),(long)200,(long)1,(200)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
- #line 33 "test2.pgc"
- /* this will disconnect from "first" */
- { ECPGdisconnect(__LINE__, "CURRENT");}
- #line 36 "test2.pgc"
- { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select current_database ( )", ECPGt_EOIT,
- ECPGt_char,(res),(long)200,(long)1,(200)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
- #line 37 "test2.pgc"
- /* error here since "first" is already disconnected */
- { ECPGdisconnect(__LINE__, id);}
- =====================================================================
- Found a 15 line (129 tokens) duplication in the following files:
- Starting at line 201 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 679 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
- ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
- #line 70 "cursor.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 70 "cursor.pgc"
- printf("%d %s\n", id, t);
- strcpy(msg, "fetch");
- { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch forward $0",
- =====================================================================
- Found a 32 line (129 tokens) duplication in the following files:
- Starting at line 372 of /home/shackle/pggit/postgresql/src/backend/tsearch/ts_parse.c
- Starting at line 548 of /home/shackle/pggit/postgresql/src/backend/tsearch/ts_parse.c
- prsdata = (void *) DatumGetPointer(FunctionCall2(&prsobj->prsstart,
- PointerGetDatum(buf),
- Int32GetDatum(buflen)));
- LexizeInit(&ldata, cfg);
- do
- {
- type = DatumGetInt32(FunctionCall3(&(prsobj->prstoken),
- PointerGetDatum(prsdata),
- PointerGetDatum(&lemm),
- PointerGetDatum(&lenlemm)));
- if (type > 0 && lenlemm >= MAXSTRLEN)
- {
- #ifdef IGNORE_LONGLEXEME
- ereport(NOTICE,
- (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
- errmsg("word is too long to be indexed"),
- errdetail("Words longer than %d characters are ignored.",
- MAXSTRLEN)));
- continue;
- #else
- ereport(ERROR,
- (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
- errmsg("word is too long to be indexed"),
- errdetail("Words longer than %d characters are ignored.",
- MAXSTRLEN)));
- #endif
- }
- LexizeAddLemm(&ldata, type, lemm, lenlemm);
- =====================================================================
- Found a 11 line (129 tokens) duplication in the following files:
- Starting at line 1737 of /home/shackle/pggit/postgresql/src/backend/utils/mb/wchar.c
- Starting at line 1755 of /home/shackle/pggit/postgresql/src/backend/utils/mb/wchar.c
- {pg_mule2wchar_with_len, pg_wchar2mule_with_len, pg_mule_mblen, pg_mule_dsplen, pg_mule_verifier, 4}, /* PG_MULE_INTERNAL */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN1 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN2 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN3 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN4 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN5 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN6 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN7 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN8 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN9 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN10 */
- =====================================================================
- Found a 39 line (129 tokens) duplication in the following files:
- Starting at line 84 of /home/shackle/pggit/postgresql/src/backend/commands/seclabel.c
- Starting at line 64 of /home/shackle/pggit/postgresql/src/backend/commands/comment.c
- }
- /*
- * Translate the parser representation which identifies this object into
- * an ObjectAddress. get_object_address() will throw an error if the
- * object does not exist, and will also acquire a lock on the target to
- * guard against concurrent modifications.
- */
- address = get_object_address(stmt->objtype, stmt->object,
- &relation, ShareUpdateExclusiveLock, false);
- /* Require ownership of the target object. */
- check_object_ownership(GetUserId(), stmt->objtype, address,
- stmt->object, relation);
- /* Perform other integrity checks as needed. */
- switch (stmt->objtype)
- {
- case OBJECT_COLUMN:
- /*
- * Allow security labels only on columns of tables, views,
- * materialized views, composite types, and foreign tables (which
- * are the only relkinds for which pg_dump will dump labels).
- */
- if (relation->rd_rel->relkind != RELKIND_RELATION &&
- relation->rd_rel->relkind != RELKIND_VIEW &&
- relation->rd_rel->relkind != RELKIND_MATVIEW &&
- relation->rd_rel->relkind != RELKIND_COMPOSITE_TYPE &&
- relation->rd_rel->relkind != RELKIND_FOREIGN_TABLE &&
- relation->rd_rel->relkind != RELKIND_PARTITIONED_TABLE)
- ereport(ERROR,
- (errcode(ERRCODE_WRONG_OBJECT_TYPE),
- errmsg("\"%s\" is not a table, view, materialized view, composite type, or foreign table",
- RelationGetRelationName(relation))));
- break;
- default:
- break;
- }
- =====================================================================
- Found a 13 line (128 tokens) duplication in the following files:
- Starting at line 41 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_backup_custom.c
- Starting at line 71 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_backup_directory.c
- static void _EndData(ArchiveHandle *AH, TocEntry *te);
- static int _WriteByte(ArchiveHandle *AH, const int i);
- static int _ReadByte(ArchiveHandle *);
- static void _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len);
- static void _ReadBuf(ArchiveHandle *AH, void *buf, size_t len);
- static void _CloseArchive(ArchiveHandle *AH);
- static void _ReopenArchive(ArchiveHandle *AH);
- static void _PrintTocData(ArchiveHandle *AH, TocEntry *te);
- static void _WriteExtraToc(ArchiveHandle *AH, TocEntry *te);
- static void _ReadExtraToc(ArchiveHandle *AH, TocEntry *te);
- static void _PrintExtraToc(ArchiveHandle *AH, TocEntry *te);
- static void _PrintData(ArchiveHandle *AH);
- =====================================================================
- Found a 37 line (128 tokens) duplication in the following files:
- Starting at line 1846 of /home/shackle/pggit/postgresql/src/backend/executor/execMain.c
- Starting at line 1979 of /home/shackle/pggit/postgresql/src/backend/executor/execMain.c
- Bitmapset *updatedCols;
- /*
- * Need to first convert the tuple to the root partitioned table's row
- * type. For details, check similar comments in ExecConstraints().
- */
- if (resultRelInfo->ri_PartitionRoot)
- {
- TupleDesc old_tupdesc = RelationGetDescr(rel);
- AttrNumber *map;
- rel = resultRelInfo->ri_PartitionRoot;
- tupdesc = RelationGetDescr(rel);
- /* a reverse map */
- map = convert_tuples_by_name_map_if_req(old_tupdesc, tupdesc,
- gettext_noop("could not convert row type"));
- /*
- * Partition-specific slot's tupdesc can't be changed, so allocate a
- * new one.
- */
- if (map != NULL)
- slot = execute_attr_map_slot(map, slot,
- MakeTupleTableSlot(tupdesc, &TTSOpsVirtual));
- }
- insertedCols = GetInsertedColumns(resultRelInfo, estate);
- updatedCols = GetUpdatedColumns(resultRelInfo, estate);
- modifiedCols = bms_union(insertedCols, updatedCols);
- val_desc = ExecBuildSlotValueDescription(RelationGetRelid(rel),
- slot,
- tupdesc,
- modifiedCols,
- 64);
- ereport(ERROR,
- (errcode(ERRCODE_CHECK_VIOLATION),
- errmsg("new row for relation \"%s\" violates partition constraint",
- =====================================================================
- Found a 5 line (128 tokens) duplication in the following files:
- Starting at line 98 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
- Starting at line 102 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- =====================================================================
- Found a 9 line (128 tokens) duplication in the following files:
- Starting at line 69 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/cyrillic_and_mic/cyrillic_and_mic.c
- Starting at line 111 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/cyrillic_and_mic/cyrillic_and_mic.c
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xE1, 0xE2, 0xF7, 0xE7, 0xE4, 0xE5, 0xF6, 0xFA,
- 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xF0,
- 0xF2, 0xF3, 0xF4, 0xF5, 0xE6, 0xE8, 0xE3, 0xFE,
- 0xFB, 0xFD, 0xFF, 0xF9, 0xF8, 0xFC, 0xE0, 0xF1,
- 0xC1, 0xC2, 0xD7, 0xC7, 0xC4, 0xC5, 0xD6, 0xDA,
- 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0,
- 0xD2, 0xD3, 0xD4, 0xD5, 0xC6, 0xC8, 0xC3, 0xDE,
- 0xDB, 0xDD, 0xDF, 0xD9, 0xD8, 0xDC, 0xC0, 0xD1,
- =====================================================================
- Found a 9 line (128 tokens) duplication in the following files:
- Starting at line 211 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/cyrillic_and_mic/cyrillic_and_mic.c
- Starting at line 269 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/cyrillic_and_mic/cyrillic_and_mic.c
- 0xF1, 0x00, 0xF3, 0x00, 0x00, 0x00, 0x00, 0xF5,
- 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
- 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F,
- 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
- 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F,
- 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7,
- 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF,
- 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7,
- 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF
- =====================================================================
- Found a 9 line (128 tokens) duplication in the following files:
- Starting at line 229 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/cyrillic_and_mic/cyrillic_and_mic.c
- Starting at line 47 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/latin2_and_win1250/latin2_and_win1250.c
- Starting at line 67 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/latin2_and_win1250/latin2_and_win1250.c
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
- 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF,
- 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7,
- 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF,
- 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7,
- 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF,
- 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7,
- 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF,
- =====================================================================
- Found a 62 line (128 tokens) duplication in the following files:
- Starting at line 613 of /home/shackle/pggit/postgresql/src/backend/access/nbtree/nbtxlog.c
- Starting at line 1061 of /home/shackle/pggit/postgresql/src/backend/access/hash/hash_xlog.c
- LockBuffer(hbuffer, BT_READ);
- hpage = (Page) BufferGetPage(hbuffer);
- /*
- * Look up the heap tuple header that the index tuple points at by
- * using the heap node supplied with the xlrec. We can't use
- * heap_fetch, since it uses ReadBuffer rather than XLogReadBuffer.
- * Note that we are not looking at tuple data here, just headers.
- */
- hoffnum = ItemPointerGetOffsetNumber(&(itup->t_tid));
- hitemid = PageGetItemId(hpage, hoffnum);
- /*
- * Follow any redirections until we find something useful.
- */
- while (ItemIdIsRedirected(hitemid))
- {
- hoffnum = ItemIdGetRedirect(hitemid);
- hitemid = PageGetItemId(hpage, hoffnum);
- CHECK_FOR_INTERRUPTS();
- }
- /*
- * If the heap item has storage, then read the header and use that to
- * set latestRemovedXid.
- *
- * Some LP_DEAD items may not be accessible, so we ignore them.
- */
- if (ItemIdHasStorage(hitemid))
- {
- htuphdr = (HeapTupleHeader) PageGetItem(hpage, hitemid);
- HeapTupleHeaderAdvanceLatestRemovedXid(htuphdr, &latestRemovedXid);
- }
- else if (ItemIdIsDead(hitemid))
- {
- /*
- * Conjecture: if hitemid is dead then it had xids before the xids
- * marked on LP_NORMAL items. So we just ignore this item and move
- * onto the next, for the purposes of calculating
- * latestRemovedxids.
- */
- }
- else
- Assert(!ItemIdIsUsed(hitemid));
- UnlockReleaseBuffer(hbuffer);
- }
- UnlockReleaseBuffer(ibuffer);
- /*
- * If all heap tuples were LP_DEAD then we will be returning
- * InvalidTransactionId here, which avoids conflicts. This matches
- * existing logic which assumes that LP_DEAD tuples must already be older
- * than the latestRemovedXid on the cleanup record that set them as
- * LP_DEAD, hence must already have generated a conflict.
- */
- return latestRemovedXid;
- }
- static void
- =====================================================================
- Found a 4 line (128 tokens) duplication in the following files:
- Starting at line 138 of /home/shackle/pggit/postgresql/src/backend/access/heap/visibilitymap.c
- Starting at line 142 of /home/shackle/pggit/postgresql/src/backend/access/heap/visibilitymap.c
- 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 2, 2, 1, 1, 2, 2,
- 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 2, 2, 1, 1, 2, 2,
- 1, 1, 2, 2, 1, 1, 2, 2, 2, 2, 3, 3, 2, 2, 3, 3,
- 1, 1, 2, 2, 1, 1, 2, 2, 2, 2, 3, 3, 2, 2, 3, 3,
- =====================================================================
- Found a 5 line (128 tokens) duplication in the following files:
- Starting at line 145 of /home/shackle/pggit/postgresql/src/backend/access/heap/visibilitymap.c
- Starting at line 149 of /home/shackle/pggit/postgresql/src/backend/access/heap/visibilitymap.c
- 1, 1, 2, 2, 1, 1, 2, 2, 2, 2, 3, 3, 2, 2, 3, 3,
- 1, 1, 2, 2, 1, 1, 2, 2, 2, 2, 3, 3, 2, 2, 3, 3,
- 1, 1, 2, 2, 1, 1, 2, 2, 2, 2, 3, 3, 2, 2, 3, 3,
- 2, 2, 3, 3, 2, 2, 3, 3, 3, 3, 4, 4, 3, 3, 4, 4,
- 2, 2, 3, 3, 2, 2, 3, 3, 3, 3, 4, 4, 3, 3, 4, 4,
- =====================================================================
- Found a 31 line (127 tokens) duplication in the following files:
- Starting at line 258 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-array_of_struct.c
- Starting at line 262 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-pointer_to_struct.c
- ECPGt_varchar,(onlyname),(long)50,(long)2,sizeof(struct varchar_5),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
- #line 85 "array_of_struct.pgc"
- if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint();
- #line 85 "array_of_struct.pgc"
- if (sqlca.sqlwarn[0] == 'W') sqlprint();
- #line 85 "array_of_struct.pgc"
- if (sqlca.sqlcode < 0) sqlprint();}
- #line 85 "array_of_struct.pgc"
- printf("\nname:\n");
- for (r = 0; r < 2; r++)
- {
- printf( "name - %s\n", onlyname[r].arr );
- }
- { ECPGdisconnect(__LINE__, "ALL");
- #line 92 "array_of_struct.pgc"
- if (sqlca.sqlwarn[0] == 'W') sqlprint();
- #line 92 "array_of_struct.pgc"
- if (sqlca.sqlcode < 0) sqlprint();}
- #line 92 "array_of_struct.pgc"
- return 0;
- }
- =====================================================================
- Found a 19 line (127 tokens) duplication in the following files:
- Starting at line 387 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/compat_informix-describe.c
- Starting at line 385 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-describe.c
- Starting at line 217 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-describe.c
- Starting at line 379 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-describe.c
- count1 == sqlda3->sqld))
- exit(1);
- for (i = 1; i <= count1; i++)
- {
- { ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
- ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
- #line 168 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 168 "describe.pgc"
- { ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
- ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
- #line 169 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- =====================================================================
- Found a 14 line (127 tokens) duplication in the following files:
- Starting at line 326 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 403 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "declare $0 cursor for select id , t from t1",
- ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
- ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
- #line 108 "cursor.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 108 "cursor.pgc"
- strcpy(msg, "fetch from");
- =====================================================================
- Found a 4 line (127 tokens) duplication in the following files:
- Starting at line 72 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
- Starting at line 76 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
- Starting at line 80 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
- 0, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
- 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
- 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
- 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
- =====================================================================
- Found a 21 line (126 tokens) duplication in the following files:
- Starting at line 62 of /home/shackle/pggit/postgresql/contrib/bloom/blvalidate.c
- Starting at line 65 of /home/shackle/pggit/postgresql/src/backend/access/brin/brin_validate.c
- Starting at line 65 of /home/shackle/pggit/postgresql/src/backend/access/nbtree/nbtvalidate.c
- Starting at line 63 of /home/shackle/pggit/postgresql/src/backend/access/gin/ginvalidate.c
- Starting at line 63 of /home/shackle/pggit/postgresql/src/backend/access/gist/gistvalidate.c
- opckeytype = opcintype;
- opclassname = NameStr(classform->opcname);
- /* Fetch opfamily information */
- familytup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfamilyoid));
- if (!HeapTupleIsValid(familytup))
- elog(ERROR, "cache lookup failed for operator family %u", opfamilyoid);
- familyform = (Form_pg_opfamily) GETSTRUCT(familytup);
- opfamilyname = NameStr(familyform->opfname);
- /* Fetch all operators and support functions of the opfamily */
- oprlist = SearchSysCacheList1(AMOPSTRATEGY, ObjectIdGetDatum(opfamilyoid));
- proclist = SearchSysCacheList1(AMPROCNUM, ObjectIdGetDatum(opfamilyoid));
- /* Check individual support functions */
- for (i = 0; i < proclist->n_members; i++)
- {
- HeapTuple proctup = &proclist->members[i]->tuple;
- Form_pg_amproc procform = (Form_pg_amproc) GETSTRUCT(proctup);
- bool ok;
- =====================================================================
- Found a 3 line (126 tokens) duplication in the following files:
- Starting at line 31 of /home/shackle/pggit/postgresql/src/common/base64.c
- Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
- Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 207 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
- =====================================================================
- Found a 3 line (126 tokens) duplication in the following files:
- Starting at line 31 of /home/shackle/pggit/postgresql/src/common/base64.c
- Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
- Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 207 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
- =====================================================================
- Found a 19 line (126 tokens) duplication in the following files:
- Starting at line 84 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-desc.c
- Starting at line 210 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-desc.c
- { ECPGset_desc(__LINE__, "indesc", 1,ECPGd_data,
- ECPGt_int,&(val1),(long)1,(long)1,sizeof(int), ECPGd_EODT);
- #line 25 "desc.pgc"
- if (sqlca.sqlcode < 0) sqlprint();}
- #line 25 "desc.pgc"
- { ECPGset_desc(__LINE__, "indesc", 2,ECPGd_data,
- ECPGt_char,(val2),(long)4,(long)1,(4)*sizeof(char), ECPGd_indicator,
- ECPGt_int,&(val2i),(long)1,(long)1,sizeof(int), ECPGd_EODT);
- #line 26 "desc.pgc"
- if (sqlca.sqlcode < 0) sqlprint();}
- #line 26 "desc.pgc"
- { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0);
- =====================================================================
- Found a 37 line (126 tokens) duplication in the following files:
- Starting at line 1023 of /home/shackle/pggit/postgresql/src/backend/regex/regc_nfa.c
- Starting at line 1109 of /home/shackle/pggit/postgresql/src/backend/regex/regc_nfa.c
- }
- else
- {
- /*
- * With many arcs, use a sort-merge approach. Note that createarc()
- * will put new arcs onto the front of newState's chain, so it does
- * not break our walk through the sorted part of the chain.
- */
- struct arc *oa;
- struct arc *na;
- /*
- * Because we bypass newarc() in this code path, we'd better include a
- * cancel check.
- */
- if (CANCEL_REQUESTED(nfa->v->re))
- {
- NERR(REG_CANCEL);
- return;
- }
- sortouts(nfa, oldState);
- sortouts(nfa, newState);
- if (NISERR())
- return; /* might have failed to sort */
- oa = oldState->outs;
- na = newState->outs;
- while (oa != NULL && na != NULL)
- {
- struct arc *a = oa;
- switch (sortouts_cmp(&oa, &na))
- {
- case -1:
- /* newState does not have anything matching oa */
- oa = oa->outchain;
- createarc(nfa, a->type, a->co, newState, a->to);
- =====================================================================
- Found a 4 line (126 tokens) duplication in the following files:
- Starting at line 72 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
- Starting at line 80 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
- Starting at line 84 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
- 0, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
- 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
- 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
- 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
- =====================================================================
- Found a 5 line (126 tokens) duplication in the following files:
- Starting at line 98 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
- Starting at line 103 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- =====================================================================
- Found a 35 line (126 tokens) duplication in the following files:
- Starting at line 509 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/funcapi.c
- Starting at line 708 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/funcapi.c
- if (!OidIsValid(anyelement_type) && !OidIsValid(anyarray_type) &&
- !OidIsValid(anyrange_type))
- return false;
- /* If needed, deduce one polymorphic type from others */
- if (have_anyelement_result && !OidIsValid(anyelement_type))
- {
- if (OidIsValid(anyarray_type))
- anyelement_type = resolve_generic_type(ANYELEMENTOID,
- anyarray_type,
- ANYARRAYOID);
- if (OidIsValid(anyrange_type))
- {
- Oid subtype = resolve_generic_type(ANYELEMENTOID,
- anyrange_type,
- ANYRANGEOID);
- /* check for inconsistent array and range results */
- if (OidIsValid(anyelement_type) && anyelement_type != subtype)
- return false;
- anyelement_type = subtype;
- }
- }
- if (have_anyarray_result && !OidIsValid(anyarray_type))
- anyarray_type = resolve_generic_type(ANYARRAYOID,
- anyelement_type,
- ANYELEMENTOID);
- /*
- * We can't deduce a range type from other polymorphic inputs, because
- * there may be multiple range types for the same subtype.
- */
- if (have_anyrange_result && !OidIsValid(anyrange_type))
- return false;
- =====================================================================
- Found a 34 line (126 tokens) duplication in the following files:
- Starting at line 1165 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
- Starting at line 2076 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
- haveTextMonth, fmask,
- &tmask, tm,
- fsec, &is2digits);
- if (dterr)
- return dterr;
- }
- }
- break;
- case DTK_STRING:
- case DTK_SPECIAL:
- /* timezone abbrevs take precedence over built-in tokens */
- type = DecodeTimezoneAbbrev(i, field[i], &val, &valtz);
- if (type == UNKNOWN_FIELD)
- type = DecodeSpecial(i, field[i], &val);
- if (type == IGNORE_DTF)
- continue;
- tmask = DTK_M(type);
- switch (type)
- {
- case RESERV:
- switch (val)
- {
- case DTK_CURRENT:
- ereport(ERROR,
- (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("date/time value \"current\" is no longer supported")));
- return DTERR_BAD_FORMAT;
- break;
- case DTK_NOW:
- tmask = (DTK_DATE_M | DTK_TIME_M | DTK_M(TZ));
- =====================================================================
- Found a 30 line (125 tokens) duplication in the following files:
- Starting at line 376 of /home/shackle/pggit/postgresql/contrib/pageinspect/btreefuncs.c
- Starting at line 461 of /home/shackle/pggit/postgresql/contrib/pageinspect/btreefuncs.c
- opaque = (BTPageOpaque) PageGetSpecialPointer(uargs->page);
- if (P_ISDELETED(opaque))
- elog(NOTICE, "page is deleted");
- fctx->max_calls = PageGetMaxOffsetNumber(uargs->page);
- /* Build a tuple descriptor for our result type */
- if (get_call_result_type(fcinfo, NULL, &tupleDesc) != TYPEFUNC_COMPOSITE)
- elog(ERROR, "return type must be a row type");
- fctx->attinmeta = TupleDescGetAttInMetadata(tupleDesc);
- fctx->user_fctx = uargs;
- MemoryContextSwitchTo(mctx);
- }
- fctx = SRF_PERCALL_SETUP();
- uargs = fctx->user_fctx;
- if (fctx->call_cntr < fctx->max_calls)
- {
- result = bt_page_print_tuples(fctx, uargs->page, uargs->offset);
- uargs->offset++;
- SRF_RETURN_NEXT(fctx, result);
- }
- else
- {
- pfree(uargs->page);
- =====================================================================
- Found a 27 line (125 tokens) duplication in the following files:
- Starting at line 425 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/interval.c
- Starting at line 3182 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
- case INTERVAL_MASK(MINUTE) | INTERVAL_MASK(SECOND):
- type = DTK_SECOND;
- break;
- default:
- type = DTK_SECOND;
- break;
- }
- }
- errno = 0;
- val = strtoint(field[i], &cp, 10);
- if (errno == ERANGE)
- return DTERR_FIELD_OVERFLOW;
- if (*cp == '-')
- {
- /* SQL "years-months" syntax */
- int val2;
- val2 = strtoint(cp + 1, &cp, 10);
- if (errno == ERANGE || val2 < 0 || val2 >= MONTHS_PER_YEAR)
- return DTERR_FIELD_OVERFLOW;
- if (*cp != '\0')
- return DTERR_BAD_FORMAT;
- type = DTK_MONTH;
- if (*field[i] == '-')
- val2 = -val2;
- =====================================================================
- Found a 34 line (125 tokens) duplication in the following files:
- Starting at line 1068 of /home/shackle/pggit/postgresql/src/backend/optimizer/plan/createplan.c
- Starting at line 1218 of /home/shackle/pggit/postgresql/src/backend/optimizer/plan/createplan.c
- subplans = lappend(subplans, subplan);
- }
- /*
- * If any quals exist, they may be useful to perform further partition
- * pruning during execution. Gather information needed by the executor to
- * do partition pruning.
- */
- if (enable_partition_pruning &&
- rel->reloptkind == RELOPT_BASEREL &&
- best_path->partitioned_rels != NIL)
- {
- List *prunequal;
- prunequal = extract_actual_clauses(rel->baserestrictinfo, false);
- if (best_path->path.param_info)
- {
- List *prmquals = best_path->path.param_info->ppi_clauses;
- prmquals = extract_actual_clauses(prmquals, false);
- prmquals = (List *) replace_nestloop_params(root,
- (Node *) prmquals);
- prunequal = list_concat(prunequal, prmquals);
- }
- if (prunequal != NIL)
- partpruneinfo =
- make_partition_pruneinfo(root, rel,
- best_path->subpaths,
- best_path->partitioned_rels,
- prunequal);
- }
- =====================================================================
- Found a 29 line (125 tokens) duplication in the following files:
- Starting at line 907 of /home/shackle/pggit/postgresql/src/backend/utils/adt/arrayfuncs.c
- Starting at line 1507 of /home/shackle/pggit/postgresql/src/backend/utils/adt/arrayfuncs.c
- }
- /*
- * Check for nulls, compute total data space needed
- */
- hasnull = false;
- totbytes = 0;
- for (i = 0; i < nitems; i++)
- {
- if (nulls[i])
- hasnull = true;
- else
- {
- /* let's just make sure data is not toasted */
- if (typlen == -1)
- values[i] = PointerGetDatum(PG_DETOAST_DATUM(values[i]));
- totbytes = att_addlength_datum(totbytes, typlen, values[i]);
- totbytes = att_align_nominal(totbytes, typalign);
- /* check for overflow of total request */
- if (!AllocSizeIsValid(totbytes))
- ereport(ERROR,
- (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
- errmsg("array size exceeds the maximum allowed (%d)",
- (int) MaxAllocSize)));
- }
- }
- *hasnulls = hasnull;
- *nbytes = totbytes;
- }
- =====================================================================
- Found a 55 line (125 tokens) duplication in the following files:
- Starting at line 971 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
- Starting at line 1480 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
- if (cmpresult < 0)
- {
- /* arg1 is less than arg2 */
- result = -1;
- break;
- }
- else if (cmpresult > 0)
- {
- /* arg1 is greater than arg2 */
- result = 1;
- break;
- }
- }
- /* equal, so continue to next column */
- i1++, i2++, j++;
- }
- /*
- * If we didn't break out of the loop early, check for column count
- * mismatch. (We do not report such mismatch if we found unequal column
- * values; is that a feature or a bug?)
- */
- if (result == 0)
- {
- if (i1 != ncolumns1 || i2 != ncolumns2)
- ereport(ERROR,
- (errcode(ERRCODE_DATATYPE_MISMATCH),
- errmsg("cannot compare record types with different numbers of columns")));
- }
- pfree(values1);
- pfree(nulls1);
- pfree(values2);
- pfree(nulls2);
- ReleaseTupleDesc(tupdesc1);
- ReleaseTupleDesc(tupdesc2);
- /* Avoid leaking memory when handed toasted input. */
- PG_FREE_IF_COPY(record1, 0);
- PG_FREE_IF_COPY(record2, 1);
- return result;
- }
- /*
- * record_eq :
- * compares two records for equality
- * result :
- * returns true if the records are equal, false otherwise.
- *
- * Note: we do not use record_cmp here, since equality may be meaningful in
- * datatypes that don't have a total ordering (and hence no btree support).
- */
- Datum
- =====================================================================
- Found a 25 line (125 tokens) duplication in the following files:
- Starting at line 308 of /home/shackle/pggit/postgresql/src/backend/access/nbtree/nbtpage.c
- Starting at line 520 of /home/shackle/pggit/postgresql/src/backend/access/nbtree/nbtpage.c
- Starting at line 608 of /home/shackle/pggit/postgresql/src/backend/access/nbtree/nbtpage.c
- metabuf = _bt_getbuf(rel, BTREE_METAPAGE, BT_READ);
- metapg = BufferGetPage(metabuf);
- metaopaque = (BTPageOpaque) PageGetSpecialPointer(metapg);
- metad = BTPageGetMeta(metapg);
- /* sanity-check the metapage */
- if (!P_ISMETA(metaopaque) ||
- metad->btm_magic != BTREE_MAGIC)
- ereport(ERROR,
- (errcode(ERRCODE_INDEX_CORRUPTED),
- errmsg("index \"%s\" is not a btree",
- RelationGetRelationName(rel))));
- if (metad->btm_version < BTREE_MIN_VERSION ||
- metad->btm_version > BTREE_VERSION)
- ereport(ERROR,
- (errcode(ERRCODE_INDEX_CORRUPTED),
- errmsg("version mismatch in index \"%s\": file version %d, "
- "current version %d, minimal supported version %d",
- RelationGetRelationName(rel),
- metad->btm_version, BTREE_VERSION, BTREE_MIN_VERSION)));
- /* if no root page initialized yet, do it */
- if (metad->btm_root == P_NONE)
- {
- =====================================================================
- Found a 42 line (125 tokens) duplication in the following files:
- Starting at line 349 of /home/shackle/pggit/postgresql/src/backend/replication/logical/worker.c
- Starting at line 423 of /home/shackle/pggit/postgresql/src/backend/replication/logical/worker.c
- values[remoteattnum] != NULL)
- {
- Oid typinput;
- Oid typioparam;
- errarg.local_attnum = i;
- errarg.remote_attnum = remoteattnum;
- getTypeInputInfo(att->atttypid, &typinput, &typioparam);
- slot->tts_values[i] =
- OidInputFunctionCall(typinput, values[remoteattnum],
- typioparam, att->atttypmod);
- slot->tts_isnull[i] = false;
- errarg.local_attnum = -1;
- errarg.remote_attnum = -1;
- }
- else
- {
- /*
- * We assign NULL to dropped attributes, NULL values, and missing
- * values (missing values should be later filled using
- * slot_fill_defaults).
- */
- slot->tts_values[i] = (Datum) 0;
- slot->tts_isnull[i] = true;
- }
- }
- /* Pop the error context stack */
- error_context_stack = errcallback.previous;
- ExecStoreVirtualTuple(slot);
- }
- /*
- * Modify slot with user data provided as C strings.
- * This is somewhat similar to heap_modify_tuple but also calls the type
- * input function on the user data as the input is the text representation
- * of the types.
- */
- static void
- =====================================================================
- Found a 33 line (124 tokens) duplication in the following files:
- Starting at line 5504 of /home/shackle/pggit/postgresql/src/pl/plpgsql/src/pl_exec.c
- Starting at line 5595 of /home/shackle/pggit/postgresql/src/pl/plpgsql/src/pl_exec.c
- break;
- }
- case PLPGSQL_DTYPE_RECFIELD:
- {
- PLpgSQL_recfield *recfield = (PLpgSQL_recfield *) datum;
- PLpgSQL_rec *rec;
- rec = (PLpgSQL_rec *) (estate->datums[recfield->recparentno]);
- /*
- * If record variable is NULL, instantiate it if it has a
- * named composite type, else complain. (This won't change
- * the logical state of the record: it's still NULL.)
- */
- if (rec->erh == NULL)
- instantiate_empty_record_variable(estate, rec);
- /*
- * Look up the field's properties if we have not already, or
- * if the tuple descriptor ID changed since last time.
- */
- if (unlikely(recfield->rectupledescid != rec->erh->er_tupdesc_id))
- {
- if (!expanded_record_lookup_field(rec->erh,
- recfield->fieldname,
- &recfield->finfo))
- ereport(ERROR,
- (errcode(ERRCODE_UNDEFINED_COLUMN),
- errmsg("record \"%s\" has no field \"%s\"",
- rec->refname, recfield->fieldname)));
- recfield->rectupledescid = rec->erh->er_tupdesc_id;
- }
- =====================================================================
- Found a 28 line (124 tokens) duplication in the following files:
- Starting at line 506 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/dt_common.c
- Starting at line 3798 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
- datebsearch(const char *key, const datetkn *base, unsigned int nel)
- {
- if (nel > 0)
- {
- const datetkn *last = base + nel - 1,
- *position;
- int result;
- while (last >= base)
- {
- position = base + ((last - base) >> 1);
- /* precheck the first character for a bit of extra speed */
- result = (int) key[0] - (int) position->token[0];
- if (result == 0)
- {
- /* use strncmp so that we match truncated tokens */
- result = strncmp(key, position->token, TOKMAXLEN);
- if (result == 0)
- return position;
- }
- if (result < 0)
- last = position - 1;
- else
- base = position + 1;
- }
- }
- return NULL;
- }
- =====================================================================
- Found a 31 line (124 tokens) duplication in the following files:
- Starting at line 140 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-func.c
- Starting at line 213 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-fetch.c
- { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table Log", ECPGt_EOIT, ECPGt_EORT);
- #line 41 "func.pgc"
- if (sqlca.sqlwarn[0] == 'W') sqlprint();
- #line 41 "func.pgc"
- if (sqlca.sqlcode < 0) sqlprint();}
- #line 41 "func.pgc"
- { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table My_Table", ECPGt_EOIT, ECPGt_EORT);
- #line 42 "func.pgc"
- if (sqlca.sqlwarn[0] == 'W') sqlprint();
- #line 42 "func.pgc"
- if (sqlca.sqlcode < 0) sqlprint();}
- #line 42 "func.pgc"
- { ECPGdisconnect(__LINE__, "ALL");
- #line 44 "func.pgc"
- if (sqlca.sqlwarn[0] == 'W') sqlprint();
- #line 44 "func.pgc"
- if (sqlca.sqlcode < 0) sqlprint();}
- #line 44 "func.pgc"
- return 0;
- }
- =====================================================================
- Found a 5 line (124 tokens) duplication in the following files:
- Starting at line 98 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
- Starting at line 103 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- =====================================================================
- Found a 28 line (124 tokens) duplication in the following files:
- Starting at line 1262 of /home/shackle/pggit/postgresql/src/backend/utils/adt/jsonb.c
- Starting at line 2303 of /home/shackle/pggit/postgresql/src/backend/utils/adt/json.c
- goto close_object;
- break;
- case 1:
- if ((ARR_DIMS(in_array)[0]) % 2)
- ereport(ERROR,
- (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
- errmsg("array must have even number of elements")));
- break;
- case 2:
- if ((ARR_DIMS(in_array)[1]) != 2)
- ereport(ERROR,
- (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
- errmsg("array must have two columns")));
- break;
- default:
- ereport(ERROR,
- (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
- errmsg("wrong number of array subscripts")));
- }
- deconstruct_array(in_array,
- TEXTOID, -1, false, 'i',
- &in_datums, &in_nulls, &in_count);
- count = in_count / 2;
- =====================================================================
- Found a 34 line (124 tokens) duplication in the following files:
- Starting at line 372 of /home/shackle/pggit/postgresql/src/backend/utils/adt/network_gist.c
- Starting at line 434 of /home/shackle/pggit/postgresql/src/backend/utils/adt/network_gist.c
- tmp = DatumGetInetKeyP(ent[i].key);
- /* Determine range of family numbers */
- if (minfamily > gk_ip_family(tmp))
- minfamily = gk_ip_family(tmp);
- if (maxfamily < gk_ip_family(tmp))
- maxfamily = gk_ip_family(tmp);
- /* Find minimum minbits */
- if (minbits > gk_ip_minbits(tmp))
- minbits = gk_ip_minbits(tmp);
- /* Find minimum number of bits in common */
- if (commonbits > gk_ip_commonbits(tmp))
- commonbits = gk_ip_commonbits(tmp);
- if (commonbits > 0)
- commonbits = bitncommon(addr, gk_ip_addr(tmp), commonbits);
- }
- /* Force minbits/commonbits to zero if more than one family. */
- if (minfamily != maxfamily)
- minbits = commonbits = 0;
- *minfamily_p = minfamily;
- *maxfamily_p = maxfamily;
- *minbits_p = minbits;
- *commonbits_p = commonbits;
- }
- /*
- * Same as above, but the GISTENTRY elements to examine are those with
- * indices listed in the offsets[] array.
- */
- static void
- =====================================================================
- Found a 38 line (124 tokens) duplication in the following files:
- Starting at line 496 of /home/shackle/pggit/postgresql/src/backend/access/heap/heapam.c
- Starting at line 800 of /home/shackle/pggit/postgresql/src/backend/access/heap/heapam.c
- int lines;
- OffsetNumber lineoff;
- int linesleft;
- ItemId lpp;
- /*
- * calculate next starting lineoff, given scan direction
- */
- if (ScanDirectionIsForward(dir))
- {
- if (!scan->rs_inited)
- {
- /*
- * return null immediately if relation is empty
- */
- if (scan->rs_nblocks == 0 || scan->rs_numblocks == 0)
- {
- Assert(!BufferIsValid(scan->rs_cbuf));
- tuple->t_data = NULL;
- return;
- }
- if (scan->rs_parallel != NULL)
- {
- heap_parallelscan_startblock_init(scan);
- page = heap_parallelscan_nextpage(scan);
- /* Other processes might have already finished the scan. */
- if (page == InvalidBlockNumber)
- {
- Assert(!BufferIsValid(scan->rs_cbuf));
- tuple->t_data = NULL;
- return;
- }
- }
- else
- page = scan->rs_startblock; /* first page */
- heapgetpage(scan, page);
- =====================================================================
- Found a 34 line (123 tokens) duplication in the following files:
- Starting at line 50 of /home/shackle/pggit/postgresql/contrib/hstore_plpython/hstore_plpython.c
- Starting at line 34 of /home/shackle/pggit/postgresql/contrib/hstore_plperl/hstore_plperl.c
- AssertVariableIsOfType(&hstoreUpgrade, hstoreUpgrade_t);
- hstoreUpgrade_p = (hstoreUpgrade_t)
- load_external_function("$libdir/hstore", "hstoreUpgrade",
- true, NULL);
- AssertVariableIsOfType(&hstoreUniquePairs, hstoreUniquePairs_t);
- hstoreUniquePairs_p = (hstoreUniquePairs_t)
- load_external_function("$libdir/hstore", "hstoreUniquePairs",
- true, NULL);
- AssertVariableIsOfType(&hstorePairs, hstorePairs_t);
- hstorePairs_p = (hstorePairs_t)
- load_external_function("$libdir/hstore", "hstorePairs",
- true, NULL);
- AssertVariableIsOfType(&hstoreCheckKeyLen, hstoreCheckKeyLen_t);
- hstoreCheckKeyLen_p = (hstoreCheckKeyLen_t)
- load_external_function("$libdir/hstore", "hstoreCheckKeyLen",
- true, NULL);
- AssertVariableIsOfType(&hstoreCheckValLen, hstoreCheckValLen_t);
- hstoreCheckValLen_p = (hstoreCheckValLen_t)
- load_external_function("$libdir/hstore", "hstoreCheckValLen",
- true, NULL);
- }
- /* These defines must be after the module init function */
- #define PLyObject_AsString PLyObject_AsString_p
- #define PLyUnicode_FromStringAndSize PLyUnicode_FromStringAndSize_p
- #define hstoreUpgrade hstoreUpgrade_p
- #define hstoreUniquePairs hstoreUniquePairs_p
- #define hstorePairs hstorePairs_p
- #define hstoreCheckKeyLen hstoreCheckKeyLen_p
- #define hstoreCheckValLen hstoreCheckValLen_p
- PG_FUNCTION_INFO_V1(hstore_to_plpython);
- =====================================================================
- Found a 20 line (123 tokens) duplication in the following files:
- Starting at line 62 of /home/shackle/pggit/postgresql/contrib/bloom/blvalidate.c
- Starting at line 63 of /home/shackle/pggit/postgresql/src/backend/access/gin/ginvalidate.c
- Starting at line 63 of /home/shackle/pggit/postgresql/src/backend/access/gist/gistvalidate.c
- Starting at line 70 of /home/shackle/pggit/postgresql/src/backend/access/hash/hashvalidate.c
- opckeytype = opcintype;
- opclassname = NameStr(classform->opcname);
- /* Fetch opfamily information */
- familytup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfamilyoid));
- if (!HeapTupleIsValid(familytup))
- elog(ERROR, "cache lookup failed for operator family %u", opfamilyoid);
- familyform = (Form_pg_opfamily) GETSTRUCT(familytup);
- opfamilyname = NameStr(familyform->opfname);
- /* Fetch all operators and support functions of the opfamily */
- oprlist = SearchSysCacheList1(AMOPSTRATEGY, ObjectIdGetDatum(opfamilyoid));
- proclist = SearchSysCacheList1(AMPROCNUM, ObjectIdGetDatum(opfamilyoid));
- /* Check individual support functions */
- for (i = 0; i < proclist->n_members; i++)
- {
- HeapTuple proctup = &proclist->members[i]->tuple;
- Form_pg_amproc procform = (Form_pg_amproc) GETSTRUCT(proctup);
- =====================================================================
- Found a 3 line (123 tokens) duplication in the following files:
- Starting at line 31 of /home/shackle/pggit/postgresql/src/common/base64.c
- Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
- Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 207 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
- =====================================================================
- Found a 3 line (123 tokens) duplication in the following files:
- Starting at line 31 of /home/shackle/pggit/postgresql/src/common/base64.c
- Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
- Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 207 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
- =====================================================================
- Found a 35 line (123 tokens) duplication in the following files:
- Starting at line 507 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-sqlda.c
- Starting at line 446 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-describe.c
- { ECPGdisconnect(__LINE__, "con2");
- #line 248 "sqlda.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 248 "sqlda.pgc"
- /* End test */
- strcpy(msg, "drop");
- { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT);
- #line 253 "sqlda.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 253 "sqlda.pgc"
- strcpy(msg, "commit");
- { ECPGtrans(__LINE__, NULL, "commit");
- #line 256 "sqlda.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 256 "sqlda.pgc"
- strcpy(msg, "disconnect");
- { ECPGdisconnect(__LINE__, "CURRENT");
- #line 259 "sqlda.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 259 "sqlda.pgc"
- return 0;
- }
- =====================================================================
- Found a 27 line (123 tokens) duplication in the following files:
- Starting at line 76 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-describe.c
- Starting at line 59 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-describe.c
- char field_name2 [ 30 ] = "not set" ;
- /* exec sql end declare section */
- #line 20 "describe.pgc"
- char msg[128];
- ECPGdebug(1, stderr);
- strcpy(msg, "connect");
- { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0);
- #line 27 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 27 "describe.pgc"
- strcpy(msg, "set");
- { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
- #line 30 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 30 "describe.pgc"
- strcpy(msg, "create");
- { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table descr_t2 ( id serial primary key , t text )", ECPGt_EOIT, ECPGt_EORT);
- =====================================================================
- Found a 10 line (123 tokens) duplication in the following files:
- Starting at line 326 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 340 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 355 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 370 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 388 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 403 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 417 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 435 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- { ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "declare $0 cursor for select id , t from t1",
- ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
- ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
- #line 108 "cursor.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- =====================================================================
- Found a 21 line (123 tokens) duplication in the following files:
- Starting at line 2064 of /home/shackle/pggit/postgresql/src/backend/nodes/nodeFuncs.c
- Starting at line 3328 of /home/shackle/pggit/postgresql/src/backend/nodes/nodeFuncs.c
- break;
- case T_CoalesceExpr:
- return walker(((CoalesceExpr *) node)->args, context);
- case T_MinMaxExpr:
- return walker(((MinMaxExpr *) node)->args, context);
- case T_XmlExpr:
- {
- XmlExpr *xexpr = (XmlExpr *) node;
- if (walker(xexpr->named_args, context))
- return true;
- /* we assume walker doesn't care about arg_names */
- if (walker(xexpr->args, context))
- return true;
- }
- break;
- case T_NullTest:
- return walker(((NullTest *) node)->arg, context);
- case T_BooleanTest:
- return walker(((BooleanTest *) node)->arg, context);
- case T_CoerceToDomain:
- =====================================================================
- Found a 29 line (123 tokens) duplication in the following files:
- Starting at line 3275 of /home/shackle/pggit/postgresql/src/backend/utils/adt/jsonfuncs.c
- Starting at line 3630 of /home/shackle/pggit/postgresql/src/backend/utils/adt/jsonfuncs.c
- old_cxt = MemoryContextSwitchTo(fnmcxt);
- cache->c.io.composite.tupdesc = CreateTupleDescCopy(tupdesc);
- cache->c.io.composite.base_typid = tupdesc->tdtypeid;
- cache->c.io.composite.base_typmod = tupdesc->tdtypmod;
- MemoryContextSwitchTo(old_cxt);
- }
- }
- /* Collect record arg if we have one */
- if (have_record_arg && !PG_ARGISNULL(0))
- {
- rec = PG_GETARG_HEAPTUPLEHEADER(0);
- /*
- * When declared arg type is RECORD, identify actual record type from
- * the tuple itself. Note the lookup_rowtype_tupdesc call in
- * update_cached_tupdesc will fail if we're unable to do this.
- */
- if (cache->argtype == RECORDOID)
- {
- cache->c.io.composite.base_typid = HeapTupleHeaderGetTypeId(rec);
- cache->c.io.composite.base_typmod = HeapTupleHeaderGetTypMod(rec);
- }
- }
- else
- rec = NULL;
- /* If no JSON argument, just return the record (if any) unchanged */
- if (PG_ARGISNULL(json_arg_num))
- =====================================================================
- Found a 25 line (123 tokens) duplication in the following files:
- Starting at line 173 of /home/shackle/pggit/postgresql/src/backend/utils/adt/inet_net_pton.c
- Starting at line 293 of /home/shackle/pggit/postgresql/src/backend/utils/adt/inet_net_pton.c
- bits = -1;
- if (ch == '/' && isdigit((unsigned char) src[0]) && dst > odst)
- {
- /* CIDR width specifier. Nothing can follow it. */
- ch = *src++; /* Skip over the /. */
- bits = 0;
- do
- {
- n = strchr(digits, ch) - digits;
- assert(n >= 0 && n <= 9);
- bits *= 10;
- bits += n;
- } while ((ch = *src++) != '\0' && isdigit((unsigned char) ch));
- if (ch != '\0')
- goto enoent;
- if (bits > 32)
- goto emsgsize;
- }
- /* Firey death and destruction unless we prefetched EOS. */
- if (ch != '\0')
- goto enoent;
- /* If nothing was written to the destination, we found no address. */
- if (dst == odst)
- =====================================================================
- Found a 42 line (123 tokens) duplication in the following files:
- Starting at line 2257 of /home/shackle/pggit/postgresql/src/backend/commands/event_trigger.c
- Starting at line 2339 of /home/shackle/pggit/postgresql/src/backend/commands/event_trigger.c
- return "TYPE";
- /* these currently aren't used */
- case OBJECT_ACCESS_METHOD:
- case OBJECT_AGGREGATE:
- case OBJECT_AMOP:
- case OBJECT_AMPROC:
- case OBJECT_ATTRIBUTE:
- case OBJECT_CAST:
- case OBJECT_COLLATION:
- case OBJECT_CONVERSION:
- case OBJECT_DEFAULT:
- case OBJECT_DEFACL:
- case OBJECT_DOMCONSTRAINT:
- case OBJECT_EVENT_TRIGGER:
- case OBJECT_EXTENSION:
- case OBJECT_FOREIGN_TABLE:
- case OBJECT_INDEX:
- case OBJECT_MATVIEW:
- case OBJECT_OPCLASS:
- case OBJECT_OPERATOR:
- case OBJECT_OPFAMILY:
- case OBJECT_POLICY:
- case OBJECT_PUBLICATION:
- case OBJECT_PUBLICATION_REL:
- case OBJECT_ROLE:
- case OBJECT_RULE:
- case OBJECT_STATISTIC_EXT:
- case OBJECT_SUBSCRIPTION:
- case OBJECT_TABCONSTRAINT:
- case OBJECT_TRANSFORM:
- case OBJECT_TRIGGER:
- case OBJECT_TSCONFIGURATION:
- case OBJECT_TSDICTIONARY:
- case OBJECT_TSPARSER:
- case OBJECT_TSTEMPLATE:
- case OBJECT_USER_MAPPING:
- case OBJECT_VIEW:
- elog(ERROR, "unsupported object type: %d", (int) objtype);
- }
- return "???"; /* keep compiler quiet */
- }
- =====================================================================
- Found a 33 line (123 tokens) duplication in the following files:
- Starting at line 94 of /home/shackle/pggit/postgresql/src/backend/access/rmgrdesc/xactdesc.c
- Starting at line 178 of /home/shackle/pggit/postgresql/src/backend/access/rmgrdesc/xactdesc.c
- data += xl_invals->nmsgs * sizeof(SharedInvalidationMessage);
- }
- if (parsed->xinfo & XACT_XINFO_HAS_TWOPHASE)
- {
- xl_xact_twophase *xl_twophase = (xl_xact_twophase *) data;
- parsed->twophase_xid = xl_twophase->xid;
- data += sizeof(xl_xact_twophase);
- if (parsed->xinfo & XACT_XINFO_HAS_GID)
- {
- strlcpy(parsed->twophase_gid, data, sizeof(parsed->twophase_gid));
- data += strlen(data) + 1;
- }
- }
- /* Note: no alignment is guaranteed after this point */
- if (parsed->xinfo & XACT_XINFO_HAS_ORIGIN)
- {
- xl_xact_origin xl_origin;
- /* no alignment is guaranteed, so copy onto stack */
- memcpy(&xl_origin, data, sizeof(xl_origin));
- parsed->origin_lsn = xl_origin.origin_lsn;
- parsed->origin_timestamp = xl_origin.origin_timestamp;
- data += sizeof(xl_xact_origin);
- }
- }
- =====================================================================
- Found a 33 line (123 tokens) duplication in the following files:
- Starting at line 87 of /home/shackle/pggit/postgresql/src/backend/access/tablesample/bernoulli.c
- Starting at line 90 of /home/shackle/pggit/postgresql/src/backend/access/tablesample/system.c
- bernoulli_samplescangetsamplesize(PlannerInfo *root,
- RelOptInfo *baserel,
- List *paramexprs,
- BlockNumber *pages,
- double *tuples)
- {
- Node *pctnode;
- float4 samplefract;
- /* Try to extract an estimate for the sample percentage */
- pctnode = (Node *) linitial(paramexprs);
- pctnode = estimate_expression_value(root, pctnode);
- if (IsA(pctnode, Const) &&
- !((Const *) pctnode)->constisnull)
- {
- samplefract = DatumGetFloat4(((Const *) pctnode)->constvalue);
- if (samplefract >= 0 && samplefract <= 100 && !isnan(samplefract))
- samplefract /= 100.0f;
- else
- {
- /* Default samplefract if the value is bogus */
- samplefract = 0.1f;
- }
- }
- else
- {
- /* Default samplefract if we didn't obtain a non-null Const */
- samplefract = 0.1f;
- }
- /* We'll visit all pages of the baserel */
- *pages = baserel->pages;
- =====================================================================
- Found a 27 line (122 tokens) duplication in the following files:
- Starting at line 665 of /home/shackle/pggit/postgresql/contrib/hstore/hstore_io.c
- Starting at line 1263 of /home/shackle/pggit/postgresql/src/backend/utils/adt/jsonb.c
- Starting at line 2304 of /home/shackle/pggit/postgresql/src/backend/utils/adt/json.c
- PG_RETURN_POINTER(out);
- case 1:
- if ((ARR_DIMS(in_array)[0]) % 2)
- ereport(ERROR,
- (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
- errmsg("array must have even number of elements")));
- break;
- case 2:
- if ((ARR_DIMS(in_array)[1]) != 2)
- ereport(ERROR,
- (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
- errmsg("array must have two columns")));
- break;
- default:
- ereport(ERROR,
- (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
- errmsg("wrong number of array subscripts")));
- }
- deconstruct_array(in_array,
- TEXTOID, -1, false, 'i',
- &in_datums, &in_nulls, &in_count);
- count = in_count / 2;
- =====================================================================
- Found a 35 line (122 tokens) duplication in the following files:
- Starting at line 304 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/compat_informix-describe.c
- Starting at line 302 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-describe.c
- { ECPGdeallocate(__LINE__, 1, NULL, "st_id1");
- #line 132 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 132 "describe.pgc"
- /* Test DESCRIBE with a query not producing tuples */
- strcpy(msg, "allocate");
- ECPGallocate_desc(__LINE__, "desc1");
- #line 137 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);
- #line 137 "describe.pgc"
- ECPGallocate_desc(__LINE__, "desc2");
- #line 138 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);
- #line 138 "describe.pgc"
- strcpy(msg, "prepare");
- { ECPGprepare(__LINE__, NULL, 0, "st_id2", stmt2);
- #line 141 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 141 "describe.pgc"
- sqlda1 = sqlda2 = sqlda3 = NULL;
- strcpy(msg, "describe");
- { ECPGdescribe(__LINE__, 1, 0, NULL, "st_id2",
- =====================================================================
- Found a 31 line (122 tokens) duplication in the following files:
- Starting at line 2873 of /home/shackle/pggit/postgresql/src/backend/executor/execExprInterp.c
- Starting at line 2920 of /home/shackle/pggit/postgresql/src/backend/executor/execExprInterp.c
- tupDesc = expanded_record_get_tupdesc(erh);
- /*
- * Find field's attr record. Note we don't support system columns
- * here: a datum tuple doesn't have valid values for most of the
- * interesting system columns anyway.
- */
- if (fieldnum <= 0) /* should never happen */
- elog(ERROR, "unsupported reference to system column %d in FieldSelect",
- fieldnum);
- if (fieldnum > tupDesc->natts) /* should never happen */
- elog(ERROR, "attribute number %d exceeds number of columns %d",
- fieldnum, tupDesc->natts);
- attr = TupleDescAttr(tupDesc, fieldnum - 1);
- /* Check for dropped column, and force a NULL result if so */
- if (attr->attisdropped)
- {
- *op->resnull = true;
- return;
- }
- /* Check for type mismatch --- possible after ALTER COLUMN TYPE? */
- /* As in CheckVarSlotCompatibility, we should but can't check typmod */
- if (op->d.fieldselect.resulttype != attr->atttypid)
- ereport(ERROR,
- (errcode(ERRCODE_DATATYPE_MISMATCH),
- errmsg("attribute %d has wrong type", fieldnum),
- errdetail("Table has type %s, but query expects %s.",
- format_type_be(attr->atttypid),
- format_type_be(op->d.fieldselect.resulttype))));
- =====================================================================
- Found a 30 line (122 tokens) duplication in the following files:
- Starting at line 1852 of /home/shackle/pggit/postgresql/src/backend/executor/execMain.c
- Starting at line 1982 of /home/shackle/pggit/postgresql/src/backend/executor/execMain.c
- Starting at line 2090 of /home/shackle/pggit/postgresql/src/backend/executor/execMain.c
- if (resultRelInfo->ri_PartitionRoot)
- {
- TupleDesc old_tupdesc = RelationGetDescr(rel);
- AttrNumber *map;
- rel = resultRelInfo->ri_PartitionRoot;
- tupdesc = RelationGetDescr(rel);
- /* a reverse map */
- map = convert_tuples_by_name_map_if_req(old_tupdesc, tupdesc,
- gettext_noop("could not convert row type"));
- /*
- * Partition-specific slot's tupdesc can't be changed, so allocate a
- * new one.
- */
- if (map != NULL)
- slot = execute_attr_map_slot(map, slot,
- MakeTupleTableSlot(tupdesc, &TTSOpsVirtual));
- }
- insertedCols = GetInsertedColumns(resultRelInfo, estate);
- updatedCols = GetUpdatedColumns(resultRelInfo, estate);
- modifiedCols = bms_union(insertedCols, updatedCols);
- val_desc = ExecBuildSlotValueDescription(RelationGetRelid(rel),
- slot,
- tupdesc,
- modifiedCols,
- 64);
- ereport(ERROR,
- (errcode(ERRCODE_CHECK_VIOLATION),
- =====================================================================
- Found a 5 line (122 tokens) duplication in the following files:
- Starting at line 98 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
- Starting at line 103 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- =====================================================================
- Found a 18 line (122 tokens) duplication in the following files:
- Starting at line 1002 of /home/shackle/pggit/postgresql/src/backend/utils/adt/tsvector_op.c
- Starting at line 1083 of /home/shackle/pggit/postgresql/src/backend/utils/adt/tsvector_op.c
- if (cmp < 0)
- { /* in1 first */
- ptr->haspos = ptr1->haspos;
- ptr->len = ptr1->len;
- memcpy(data + dataoff, data1 + ptr1->pos, ptr1->len);
- ptr->pos = dataoff;
- dataoff += ptr1->len;
- if (ptr->haspos)
- {
- dataoff = SHORTALIGN(dataoff);
- memcpy(data + dataoff, _POSVECPTR(in1, ptr1), POSDATALEN(in1, ptr1) * sizeof(WordEntryPos) + sizeof(uint16));
- dataoff += POSDATALEN(in1, ptr1) * sizeof(WordEntryPos) + sizeof(uint16);
- }
- ptr++;
- ptr1++;
- i1--;
- }
- =====================================================================
- Found a 47 line (122 tokens) duplication in the following files:
- Starting at line 2124 of /home/shackle/pggit/postgresql/src/backend/commands/analyze.c
- Starting at line 2489 of /home/shackle/pggit/postgresql/src/backend/commands/analyze.c
- int f1 = nonnull_cnt - summultiple;
- int d = f1 + nmultiple;
- double n = samplerows - null_cnt;
- double N = totalrows * (1.0 - stats->stanullfrac);
- double stadistinct;
- /* N == 0 shouldn't happen, but just in case ... */
- if (N > 0)
- stadistinct = (n * d) / ((n - f1) + f1 * n / N);
- else
- stadistinct = 0;
- /* Clamp to sane range in case of roundoff error */
- if (stadistinct < d)
- stadistinct = d;
- if (stadistinct > N)
- stadistinct = N;
- /* And round to integer */
- stats->stadistinct = floor(stadistinct + 0.5);
- }
- /*
- * If we estimated the number of distinct values at more than 10% of
- * the total row count (a very arbitrary limit), then assume that
- * stadistinct should scale with the row count rather than be a fixed
- * value.
- */
- if (stats->stadistinct > 0.1 * totalrows)
- stats->stadistinct = -(stats->stadistinct / totalrows);
- /*
- * Decide how many values are worth storing as most-common values. If
- * we are able to generate a complete MCV list (all the values in the
- * sample will fit, and we think these are all the ones in the table),
- * then do so. Otherwise, store only those values that are
- * significantly more common than the values not in the list.
- *
- * Note: the first of these cases is meant to address columns with
- * small, fixed sets of possible values, such as boolean or enum
- * columns. If we can *completely* represent the column population by
- * an MCV list that will fit into the stats target, then we should do
- * so and thus provide the planner with complete information. But if
- * the MCV list is not complete, it's generally worth being more
- * selective, and not just filling it all the way up to the stats
- * target.
- */
- if (track_cnt < track_max && toowide_cnt == 0 &&
- =====================================================================
- Found a 10 line (121 tokens) duplication in the following files:
- Starting at line 44 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_backup_tar.c
- Starting at line 38 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_backup_custom.c
- static void _ArchiveEntry(ArchiveHandle *AH, TocEntry *te);
- static void _StartData(ArchiveHandle *AH, TocEntry *te);
- static void _WriteData(ArchiveHandle *AH, const void *data, size_t dLen);
- static void _EndData(ArchiveHandle *AH, TocEntry *te);
- static int _WriteByte(ArchiveHandle *AH, const int i);
- static int _ReadByte(ArchiveHandle *);
- static void _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len);
- static void _ReadBuf(ArchiveHandle *AH, void *buf, size_t len);
- static void _CloseArchive(ArchiveHandle *AH);
- static void _PrintTocData(ArchiveHandle *AH, TocEntry *te);
- =====================================================================
- Found a 36 line (121 tokens) duplication in the following files:
- Starting at line 917 of /home/shackle/pggit/postgresql/src/bin/pg_dump/dumputils.c
- Starting at line 3546 of /home/shackle/pggit/postgresql/src/backend/utils/adt/varlena.c
- while (isspace((unsigned char) *nextp))
- nextp++; /* skip leading whitespace */
- if (*nextp == '\0')
- return true; /* allow empty string */
- /* At the top of the loop, we are at start of a new identifier. */
- do
- {
- char *curname;
- char *endp;
- if (*nextp == '"')
- {
- /* Quoted name --- collapse quote-quote pairs */
- curname = nextp + 1;
- for (;;)
- {
- endp = strchr(nextp + 1, '"');
- if (endp == NULL)
- return false; /* mismatched quotes */
- if (endp[1] != '"')
- break; /* found end of quoted name */
- /* Collapse adjacent quotes into one quote, and look again */
- memmove(endp, endp + 1, strlen(endp));
- nextp = endp;
- }
- /* endp now points at the terminating quote */
- nextp = endp + 1;
- }
- else
- {
- /* Unquoted name --- extends to separator or whitespace */
- curname = nextp;
- while (*nextp && *nextp != separator &&
- !isspace((unsigned char) *nextp))
- =====================================================================
- Found a 21 line (121 tokens) duplication in the following files:
- Starting at line 93 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-show.c
- Starting at line 108 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-quote.c
- { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set standard_conforming_strings to off", ECPGt_EOIT, ECPGt_EORT);
- #line 26 "show.pgc"
- if (sqlca.sqlwarn[0] == 'W') sqlprint();
- #line 26 "show.pgc"
- if (sqlca.sqlcode < 0) sqlprint();}
- #line 26 "show.pgc"
- { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "show standard_conforming_strings", ECPGt_EOIT,
- ECPGt_char,(var),(long)25,(long)1,(25)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
- #line 27 "show.pgc"
- if (sqlca.sqlwarn[0] == 'W') sqlprint();
- #line 27 "show.pgc"
- if (sqlca.sqlcode < 0) sqlprint();}
- #line 27 "show.pgc"
- printf("Var: Standard conforming strings: %s\n", var);
- =====================================================================
- Found a 25 line (121 tokens) duplication in the following files:
- Starting at line 1247 of /home/shackle/pggit/postgresql/src/backend/executor/nodeIndexscan.c
- Starting at line 1494 of /home/shackle/pggit/postgresql/src/backend/executor/nodeIndexscan.c
- leftop = (Expr *) get_leftop(clause);
- if (leftop && IsA(leftop, RelabelType))
- leftop = ((RelabelType *) leftop)->arg;
- Assert(leftop != NULL);
- if (!(IsA(leftop, Var) &&
- ((Var *) leftop)->varno == INDEX_VAR))
- elog(ERROR, "indexqual doesn't have key on left side");
- varattno = ((Var *) leftop)->varattno;
- if (varattno < 1 || varattno > indnkeyatts)
- elog(ERROR, "bogus index qualification");
- /*
- * We have to look up the operator's strategy number. This
- * provides a cross-check that the operator does match the index.
- */
- opfamily = index->rd_opfamily[varattno - 1];
- get_op_opfamily_properties(opno, opfamily, isorderby,
- &op_strategy,
- &op_lefttype,
- &op_righttype);
- =====================================================================
- Found a 18 line (121 tokens) duplication in the following files:
- Starting at line 1213 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
- Starting at line 1520 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
- InitFunctionCallInfoData(fcinfo, flinfo, 5, collation, NULL, NULL);
- fcinfo.arg[0] = arg1;
- fcinfo.arg[1] = arg2;
- fcinfo.arg[2] = arg3;
- fcinfo.arg[3] = arg4;
- fcinfo.arg[4] = arg5;
- fcinfo.argnull[0] = false;
- fcinfo.argnull[1] = false;
- fcinfo.argnull[2] = false;
- fcinfo.argnull[3] = false;
- fcinfo.argnull[4] = false;
- result = FunctionCallInvoke(&fcinfo);
- /* Check for null result, since caller is clearly not expecting one */
- if (fcinfo.isnull)
- elog(ERROR, "function %u returned NULL", fcinfo.flinfo->fn_oid);
- =====================================================================
- Found a 28 line (121 tokens) duplication in the following files:
- Starting at line 496 of /home/shackle/pggit/postgresql/src/backend/commands/opclasscmds.c
- Starting at line 875 of /home/shackle/pggit/postgresql/src/backend/commands/opclasscmds.c
- false, -1);
- }
- if (item->order_family)
- sortfamilyOid = get_opfamily_oid(BTREE_AM_OID,
- item->order_family,
- false);
- else
- sortfamilyOid = InvalidOid;
- #ifdef NOT_USED
- /* XXX this is unnecessary given the superuser check above */
- /* Caller must own operator and its underlying function */
- if (!pg_oper_ownercheck(operOid, GetUserId()))
- aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_OPERATOR,
- get_opname(operOid));
- funcOid = get_opcode(operOid);
- if (!pg_proc_ownercheck(funcOid, GetUserId()))
- aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_FUNCTION,
- get_func_name(funcOid));
- #endif
- /* Save the info */
- member = (OpFamilyMember *) palloc0(sizeof(OpFamilyMember));
- member->object = operOid;
- member->number = item->number;
- member->sortfamily = sortfamilyOid;
- assignOperTypes(member, amoid, typeoid);
- =====================================================================
- Found a 27 line (121 tokens) duplication in the following files:
- Starting at line 2350 of /home/shackle/pggit/postgresql/src/backend/commands/typecmds.c
- Starting at line 2764 of /home/shackle/pggit/postgresql/src/backend/commands/typecmds.c
- ListCell *rt;
- /* Fetch relation list with attributes based on this domain */
- /* ShareLock is sufficient to prevent concurrent data changes */
- rels = get_rels_with_domain(domainoid, ShareLock);
- foreach(rt, rels)
- {
- RelToCheck *rtc = (RelToCheck *) lfirst(rt);
- Relation testrel = rtc->rel;
- TupleDesc tupdesc = RelationGetDescr(testrel);
- HeapScanDesc scan;
- HeapTuple tuple;
- Snapshot snapshot;
- /* Scan all tuples in this relation */
- snapshot = RegisterSnapshot(GetLatestSnapshot());
- scan = heap_beginscan(testrel, snapshot, 0, NULL);
- while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
- {
- int i;
- /* Test attributes that are of the domain */
- for (i = 0; i < rtc->natts; i++)
- {
- int attnum = rtc->atts[i];
- =====================================================================
- Found a 29 line (121 tokens) duplication in the following files:
- Starting at line 483 of /home/shackle/pggit/postgresql/src/backend/access/common/printtup.c
- Starting at line 668 of /home/shackle/pggit/postgresql/src/backend/access/common/printtup.c
- pq_beginmessage_reuse(buf, 'D');
- /*
- * send a bitmap of which attributes are not null
- */
- j = 0;
- k = 1 << 7;
- for (i = 0; i < natts; ++i)
- {
- if (!slot->tts_isnull[i])
- j |= k; /* set bit if not null */
- k >>= 1;
- if (k == 0) /* end of byte? */
- {
- pq_sendint8(buf, j);
- j = 0;
- k = 1 << 7;
- }
- }
- if (k != (1 << 7)) /* flush last partial byte */
- pq_sendint8(buf, j);
- /*
- * send the attributes of this tuple
- */
- for (i = 0; i < natts; ++i)
- {
- PrinttupAttrInfo *thisState = myState->myinfo + i;
- Datum attr = slot->tts_values[i];
- =====================================================================
- Found a 17 line (120 tokens) duplication in the following files:
- Starting at line 358 of /home/shackle/pggit/postgresql/contrib/ltree/_ltree_gist.c
- Starting at line 410 of /home/shackle/pggit/postgresql/contrib/intarray/_intbig_gist.c
- memcpy((void *) LTG_SIGN(datum_r), (void *) LTG_SIGN(GETENTRY(entryvec, seed_2)), sizeof(ABITVEC));
- }
- maxoff = OffsetNumberNext(maxoff);
- /* sort before ... */
- costvector = (SPLITCOST *) palloc(sizeof(SPLITCOST) * maxoff);
- for (j = FirstOffsetNumber; j <= maxoff; j = OffsetNumberNext(j))
- {
- costvector[j - 1].pos = j;
- _j = GETENTRY(entryvec, j);
- size_alpha = hemdist(datum_l, _j);
- size_beta = hemdist(datum_r, _j);
- costvector[j - 1].cost = Abs(size_alpha - size_beta);
- }
- qsort((void *) costvector, maxoff, sizeof(SPLITCOST), comparecost);
- union_l = LTG_SIGN(datum_l);
- =====================================================================
- Found a 3 line (120 tokens) duplication in the following files:
- Starting at line 31 of /home/shackle/pggit/postgresql/src/common/base64.c
- Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
- Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 207 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
- =====================================================================
- Found a 3 line (120 tokens) duplication in the following files:
- Starting at line 31 of /home/shackle/pggit/postgresql/src/common/base64.c
- Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
- Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 207 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
- =====================================================================
- Found a 43 line (120 tokens) duplication in the following files:
- Starting at line 1080 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/numeric.c
- Starting at line 7641 of /home/shackle/pggit/postgresql/src/backend/utils/adt/numeric.c
- int res_dscale;
- /*
- * The result scale of a division isn't specified in any SQL standard. For
- * PostgreSQL we select a display scale that will give at least
- * NUMERIC_MIN_SIG_DIGITS significant digits, so that numeric gives a
- * result no less accurate than float8; but use a scale not less than
- * either input's display scale.
- */
- /* Get the actual (normalized) weight and first digit of each input */
- weight1 = 0; /* values to use if var1 is zero */
- firstdigit1 = 0;
- for (i = 0; i < var1->ndigits; i++)
- {
- firstdigit1 = var1->digits[i];
- if (firstdigit1 != 0)
- {
- weight1 = var1->weight - i;
- break;
- }
- }
- weight2 = 0; /* values to use if var2 is zero */
- firstdigit2 = 0;
- for (i = 0; i < var2->ndigits; i++)
- {
- firstdigit2 = var2->digits[i];
- if (firstdigit2 != 0)
- {
- weight2 = var2->weight - i;
- break;
- }
- }
- /*
- * Estimate weight of quotient. If the two first digits are equal, we
- * can't be sure, but assume that var1 is less than var2.
- */
- qweight = weight1 - weight2;
- if (firstdigit1 <= firstdigit2)
- qweight--;
- =====================================================================
- Found a 27 line (120 tokens) duplication in the following files:
- Starting at line 220 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-autoprep.c
- Starting at line 95 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-parser.c
- { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur1", ECPGt_EOIT, ECPGt_EORT);
- #line 60 "autoprep.pgc"
- if (sqlca.sqlwarn[0] == 'W') sqlprint();
- #line 60 "autoprep.pgc"
- if (sqlca.sqlcode < 0) sqlprint();}
- #line 60 "autoprep.pgc"
- { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table T", ECPGt_EOIT, ECPGt_EORT);
- #line 62 "autoprep.pgc"
- if (sqlca.sqlwarn[0] == 'W') sqlprint();
- #line 62 "autoprep.pgc"
- if (sqlca.sqlcode < 0) sqlprint();}
- #line 62 "autoprep.pgc"
- { ECPGdisconnect(__LINE__, "ALL");
- #line 64 "autoprep.pgc"
- if (sqlca.sqlwarn[0] == 'W') sqlprint();
- #line 64 "autoprep.pgc"
- if (sqlca.sqlcode < 0) sqlprint();}
- =====================================================================
- Found a 23 line (120 tokens) duplication in the following files:
- Starting at line 474 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-sqlda.c
- Starting at line 462 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c
- { ECPGdo(__LINE__, 0, 1, "con2", 0, ECPGst_execute, "st_id4",
- ECPGt_sqlda, &inp_sqlda, 0L, 0L, 0L,
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
- ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L,
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
- #line 234 "sqlda.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 234 "sqlda.pgc"
- dump_sqlda(outp_sqlda);
- strcpy(msg, "commit");
- { ECPGtrans(__LINE__, "con2", "commit");
- #line 239 "sqlda.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 239 "sqlda.pgc"
- strcpy(msg, "deallocate");
- { ECPGdeallocate(__LINE__, 0, NULL, "st_id4");
- =====================================================================
- Found a 16 line (120 tokens) duplication in the following files:
- Starting at line 261 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/compat_informix-describe.c
- Starting at line 259 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-describe.c
- Starting at line 220 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-describe.c
- Starting at line 382 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-describe.c
- for (i = 1; i <= count1; i++)
- {
- { ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
- ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
- #line 115 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 115 "describe.pgc"
- { ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
- ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
- #line 116 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- =====================================================================
- Found a 5 line (120 tokens) duplication in the following files:
- Starting at line 98 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
- Starting at line 103 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- =====================================================================
- Found a 16 line (120 tokens) duplication in the following files:
- Starting at line 923 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
- Starting at line 1243 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
- Starting at line 1553 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
- InitFunctionCallInfoData(fcinfo, NULL, 6, collation, NULL, NULL);
- fcinfo.arg[0] = arg1;
- fcinfo.arg[1] = arg2;
- fcinfo.arg[2] = arg3;
- fcinfo.arg[3] = arg4;
- fcinfo.arg[4] = arg5;
- fcinfo.arg[5] = arg6;
- fcinfo.argnull[0] = false;
- fcinfo.argnull[1] = false;
- fcinfo.argnull[2] = false;
- fcinfo.argnull[3] = false;
- fcinfo.argnull[4] = false;
- fcinfo.argnull[5] = false;
- result = (*func) (&fcinfo);
- =====================================================================
- Found a 31 line (120 tokens) duplication in the following files:
- Starting at line 883 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
- Starting at line 1127 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
- Starting at line 1386 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
- Starting at line 1630 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rowtypes.c
- Oid collation;
- /*
- * Skip dropped columns
- */
- if (i1 < ncolumns1 && TupleDescAttr(tupdesc1, i1)->attisdropped)
- {
- i1++;
- continue;
- }
- if (i2 < ncolumns2 && TupleDescAttr(tupdesc2, i2)->attisdropped)
- {
- i2++;
- continue;
- }
- if (i1 >= ncolumns1 || i2 >= ncolumns2)
- break; /* we'll deal with mismatch below loop */
- att1 = TupleDescAttr(tupdesc1, i1);
- att2 = TupleDescAttr(tupdesc2, i2);
- /*
- * Have two matching columns, they must be same type
- */
- if (att1->atttypid != att2->atttypid)
- ereport(ERROR,
- (errcode(ERRCODE_DATATYPE_MISMATCH),
- errmsg("cannot compare dissimilar column types %s and %s at record column %d",
- format_type_be(att1->atttypid),
- format_type_be(att2->atttypid),
- j + 1)));
- =====================================================================
- Found a 24 line (119 tokens) duplication in the following files:
- Starting at line 375 of /home/shackle/pggit/postgresql/contrib/ltree/_ltree_gist.c
- Starting at line 427 of /home/shackle/pggit/postgresql/contrib/intarray/_intbig_gist.c
- union_r = LTG_SIGN(datum_r);
- for (k = 0; k < maxoff; k++)
- {
- j = costvector[k].pos;
- if (j == seed_1)
- {
- *left++ = j;
- v->spl_nleft++;
- continue;
- }
- else if (j == seed_2)
- {
- *right++ = j;
- v->spl_nright++;
- continue;
- }
- _j = GETENTRY(entryvec, j);
- size_alpha = hemdist(datum_l, _j);
- size_beta = hemdist(datum_r, _j);
- if (size_alpha < size_beta + WISH_F(v->spl_nleft, v->spl_nright, 0.00001))
- {
- if (LTG_ISALLTRUE(datum_l) || LTG_ISALLTRUE(_j))
- =====================================================================
- Found a 18 line (119 tokens) duplication in the following files:
- Starting at line 18 of /home/shackle/pggit/postgresql/src/bin/scripts/dropuser.c
- Starting at line 18 of /home/shackle/pggit/postgresql/src/bin/scripts/dropdb.c
- static void help(const char *progname);
- int
- main(int argc, char *argv[])
- {
- static int if_exists = 0;
- static struct option long_options[] = {
- {"host", required_argument, NULL, 'h'},
- {"port", required_argument, NULL, 'p'},
- {"username", required_argument, NULL, 'U'},
- {"no-password", no_argument, NULL, 'w'},
- {"password", no_argument, NULL, 'W'},
- {"echo", no_argument, NULL, 'e'},
- {"interactive", no_argument, NULL, 'i'},
- {"if-exists", no_argument, &if_exists, 1},
- {NULL, 0, NULL, 0}
- =====================================================================
- Found a 31 line (119 tokens) duplication in the following files:
- Starting at line 1376 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-protocol2.c
- Starting at line 1867 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-protocol3.c
- resetPQExpBuffer(&conn->errorMessage);
- /* Wait for the completion response */
- result = PQgetResult(conn);
- /* Expecting a successful result */
- if (result && result->resultStatus == PGRES_COMMAND_OK)
- {
- PQclear(result);
- return 0;
- }
- /*
- * Trouble. For backwards-compatibility reasons, we issue the error
- * message as if it were a notice (would be nice to get rid of this
- * silliness, but too many apps probably don't handle errors from
- * PQendcopy reasonably). Note that the app can still obtain the error
- * status from the PGconn object.
- */
- if (conn->errorMessage.len > 0)
- {
- /* We have to strip the trailing newline ... pain in neck... */
- char svLast = conn->errorMessage.data[conn->errorMessage.len - 1];
- if (svLast == '\n')
- conn->errorMessage.data[conn->errorMessage.len - 1] = '\0';
- pqInternalNotice(&conn->noticeHooks, "%s", conn->errorMessage.data);
- conn->errorMessage.data[conn->errorMessage.len - 1] = svLast;
- }
- PQclear(result);
- =====================================================================
- Found a 40 line (119 tokens) duplication in the following files:
- Starting at line 119 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-describe.c
- Starting at line 284 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-describe.c
- { ECPGtrans(__LINE__, NULL, "commit");
- #line 41 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 41 "describe.pgc"
- /*
- * Test DESCRIBE with a query producing tuples.
- * DESCRIPTOR and SQL DESCRIPTOR are the same in native mode.
- */
- strcpy(msg, "allocate");
- ECPGallocate_desc(__LINE__, "desc1");
- #line 49 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);
- #line 49 "describe.pgc"
- ECPGallocate_desc(__LINE__, "desc2");
- #line 50 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);
- #line 50 "describe.pgc"
- ECPGallocate_desc(__LINE__, "desc3");
- #line 51 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);
- #line 51 "describe.pgc"
- ECPGallocate_desc(__LINE__, "desc4");
- #line 52 "describe.pgc"
- if (sqlca.sqlcode < 0) exit (1);
- #line 52 "describe.pgc"
- strcpy(msg, "prepare");
- { ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1);
- =====================================================================
- Found a 18 line (119 tokens) duplication in the following files:
- Starting at line 773 of /home/shackle/pggit/postgresql/src/backend/utils/adt/ri_triggers.c
- Starting at line 913 of /home/shackle/pggit/postgresql/src/backend/utils/adt/ri_triggers.c
- appendStringInfo(&querybuf, "SELECT 1 FROM %s%s x",
- fk_only, fkrelname);
- querysep = "WHERE";
- for (i = 0; i < riinfo->nkeys; i++)
- {
- Oid pk_type = RIAttType(pk_rel, riinfo->pk_attnums[i]);
- Oid fk_type = RIAttType(fk_rel, riinfo->fk_attnums[i]);
- quoteOneName(attname,
- RIAttName(fk_rel, riinfo->fk_attnums[i]));
- sprintf(paramname, "$%d", i + 1);
- ri_GenerateQual(&querybuf, querysep,
- paramname, pk_type,
- riinfo->pf_eq_oprs[i],
- attname, fk_type);
- querysep = "AND";
- queryoids[i] = pk_type;
- }
- =====================================================================
- Found a 30 line (119 tokens) duplication in the following files:
- Starting at line 3996 of /home/shackle/pggit/postgresql/src/backend/access/transam/xact.c
- Starting at line 4105 of /home/shackle/pggit/postgresql/src/backend/access/transam/xact.c
- elog(FATAL, "ReleaseSavepoint: unexpected state %s",
- BlockStateAsString(s->blockState));
- break;
- }
- for (target = s; PointerIsValid(target); target = target->parent)
- {
- if (PointerIsValid(target->name) && strcmp(target->name, name) == 0)
- break;
- }
- if (!PointerIsValid(target))
- ereport(ERROR,
- (errcode(ERRCODE_S_E_INVALID_SPECIFICATION),
- errmsg("savepoint \"%s\" does not exist", name)));
- /* disallow crossing savepoint level boundaries */
- if (target->savepointLevel != s->savepointLevel)
- ereport(ERROR,
- (errcode(ERRCODE_S_E_INVALID_SPECIFICATION),
- errmsg("savepoint \"%s\" does not exist within current savepoint level", name)));
- /*
- * Mark "commit pending" all subtransactions up to the target
- * subtransaction. The actual commits will happen when control gets to
- * CommitTransactionCommand.
- */
- xact = CurrentTransactionState;
- for (;;)
- {
- =====================================================================
- Found a 34 line (118 tokens) duplication in the following files:
- Starting at line 5051 of /home/shackle/pggit/postgresql/src/pl/plpgsql/src/pl_exec.c
- Starting at line 5417 of /home/shackle/pggit/postgresql/src/pl/plpgsql/src/pl_exec.c
- PLpgSQL_recfield *recfield = (PLpgSQL_recfield *) target;
- PLpgSQL_rec *rec;
- ExpandedRecordHeader *erh;
- rec = (PLpgSQL_rec *) (estate->datums[recfield->recparentno]);
- erh = rec->erh;
- /*
- * If record variable is NULL, instantiate it if it has a
- * named composite type, else complain. (This won't change
- * the logical state of the record, but if we successfully
- * assign below, the unassigned fields will all become NULLs.)
- */
- if (erh == NULL)
- {
- instantiate_empty_record_variable(estate, rec);
- erh = rec->erh;
- }
- /*
- * Look up the field's properties if we have not already, or
- * if the tuple descriptor ID changed since last time.
- */
- if (unlikely(recfield->rectupledescid != erh->er_tupdesc_id))
- {
- if (!expanded_record_lookup_field(erh,
- recfield->fieldname,
- &recfield->finfo))
- ereport(ERROR,
- (errcode(ERRCODE_UNDEFINED_COLUMN),
- errmsg("record \"%s\" has no field \"%s\"",
- rec->refname, recfield->fieldname)));
- recfield->rectupledescid = erh->er_tupdesc_id;
- }
- =====================================================================
- Found a 24 line (118 tokens) duplication in the following files:
- Starting at line 3745 of /home/shackle/pggit/postgresql/src/pl/plperl/plperl.c
- Starting at line 3858 of /home/shackle/pggit/postgresql/src/pl/plperl/plperl.c
- if (argc > 0)
- {
- nulls = (char *) palloc(argc);
- argvalues = (Datum *) palloc(argc * sizeof(Datum));
- }
- else
- {
- nulls = NULL;
- argvalues = NULL;
- }
- for (i = 0; i < argc; i++)
- {
- bool isnull;
- argvalues[i] = plperl_sv_to_datum(argv[i],
- qdesc->argtypes[i],
- -1,
- NULL,
- &qdesc->arginfuncs[i],
- qdesc->argtypioparams[i],
- &isnull);
- nulls[i] = isnull ? 'n' : ' ';
- }
- =====================================================================
- Found a 18 line (118 tokens) duplication in the following files:
- Starting at line 569 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/numeric.c
- Starting at line 657 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/numeric.c
- res_weight = Max(var1->weight, var2->weight) + 1;
- res_rscale = Max(var1->rscale, var2->rscale);
- res_dscale = Max(var1->dscale, var2->dscale);
- res_ndigits = res_rscale + res_weight + 1;
- if (res_ndigits <= 0)
- res_ndigits = 1;
- if ((res_buf = digitbuf_alloc(res_ndigits)) == NULL)
- return -1;
- res_digits = res_buf;
- i1 = res_rscale + var1->weight + 1;
- i2 = res_rscale + var2->weight + 1;
- for (i = res_ndigits - 1; i >= 0; i--)
- {
- i1--;
- i2--;
- if (i1 >= 0 && i1 < var1ndigits)
- =====================================================================
- Found a 27 line (118 tokens) duplication in the following files:
- Starting at line 119 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-variable.c
- Starting at line 269 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-outofscope.c
- Starting at line 76 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-describe.c
- Starting at line 59 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-describe.c
- ind children ;
- #line 37 "variable.pgc"
- char msg[128];
- ECPGdebug(1, stderr);
- strcpy(msg, "connect");
- { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0);
- #line 44 "variable.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 44 "variable.pgc"
- strcpy(msg, "set");
- { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
- #line 47 "variable.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 47 "variable.pgc"
- strcpy(msg, "create");
- { 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);
- =====================================================================
- Found a 10 line (118 tokens) duplication in the following files:
- Starting at line 191 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.c
- Starting at line 234 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.c
- { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select id , d , d from nantest2 where id = 4", ECPGt_EOIT,
- ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_numeric,&(num),(long)1,(long)0,sizeof(numeric),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_char,(val),(long)16,(long)1,(16)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
- #line 70 "nan_test.pgc"
- if (sqlca.sqlcode < 0) sqlprint ( );}
- =====================================================================
- Found a 5 line (118 tokens) duplication in the following files:
- Starting at line 98 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
- Starting at line 103 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- =====================================================================
- Found a 36 line (118 tokens) duplication in the following files:
- Starting at line 816 of /home/shackle/pggit/postgresql/src/backend/utils/mmgr/mcxt.c
- Starting at line 959 of /home/shackle/pggit/postgresql/src/backend/utils/mmgr/mcxt.c
- void *ret;
- AssertArg(MemoryContextIsValid(context));
- AssertNotInCriticalSection(context);
- if (!AllocSizeIsValid(size))
- elog(ERROR, "invalid memory alloc request size %zu", size);
- context->isReset = false;
- ret = context->methods->alloc(context, size);
- if (unlikely(ret == NULL))
- {
- MemoryContextStats(TopMemoryContext);
- ereport(ERROR,
- (errcode(ERRCODE_OUT_OF_MEMORY),
- errmsg("out of memory"),
- errdetail("Failed on request of size %zu in memory context \"%s\".",
- size, context->name)));
- }
- VALGRIND_MEMPOOL_ALLOC(context, ret, size);
- MemSetAligned(ret, 0, size);
- return ret;
- }
- /*
- * MemoryContextAllocZeroAligned
- * MemoryContextAllocZero where length is suitable for MemSetLoop
- *
- * This might seem overly specialized, but it's not because newNode()
- * is so often called with compile-time-constant sizes.
- */
- void *
- =====================================================================
- Found a 24 line (118 tokens) duplication in the following files:
- Starting at line 415 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c
- Starting at line 197 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/euc_tw_and_big5.c
- Starting at line 106 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/euc_kr_and_mic/euc_kr_and_mic.c
- mic2euc_jp(const unsigned char *mic, unsigned char *p, int len)
- {
- int c1;
- int l;
- while (len > 0)
- {
- c1 = *mic;
- if (!IS_HIGHBIT_SET(c1))
- {
- /* ASCII */
- if (c1 == 0)
- report_invalid_encoding(PG_MULE_INTERNAL,
- (const char *) mic, len);
- *p++ = c1;
- mic++;
- len--;
- continue;
- }
- l = pg_encoding_verifymb(PG_MULE_INTERNAL, (const char *) mic, len);
- if (l < 0)
- report_invalid_encoding(PG_MULE_INTERNAL,
- (const char *) mic, len);
- if (c1 == LC_JISX0201K)
- =====================================================================
- Found a 20 line (118 tokens) duplication in the following files:
- Starting at line 3886 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
- Starting at line 4017 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
- str = pg_ltostr_zeropad(str, tm->tm_mday, 2);
- break;
- case USE_SQL_DATES:
- /* compatible with Oracle/Ingres date formats */
- if (DateOrder == DATEORDER_DMY)
- {
- str = pg_ltostr_zeropad(str, tm->tm_mday, 2);
- *str++ = '/';
- str = pg_ltostr_zeropad(str, tm->tm_mon, 2);
- }
- else
- {
- str = pg_ltostr_zeropad(str, tm->tm_mon, 2);
- *str++ = '/';
- str = pg_ltostr_zeropad(str, tm->tm_mday, 2);
- }
- *str++ = '/';
- str = pg_ltostr_zeropad(str,
- (tm->tm_year > 0) ? tm->tm_year : -(tm->tm_year - 1), 4);
- =====================================================================
- Found a 3 line (117 tokens) duplication in the following files:
- Starting at line 31 of /home/shackle/pggit/postgresql/src/common/base64.c
- Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
- Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 207 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
- =====================================================================
- Found a 3 line (117 tokens) duplication in the following files:
- Starting at line 31 of /home/shackle/pggit/postgresql/src/common/base64.c
- Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
- Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 207 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
- =====================================================================
- Found a 26 line (117 tokens) duplication in the following files:
- Starting at line 864 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/ecpglib/execute.c
- Starting at line 911 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/ecpglib/execute.c
- Starting at line 958 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/ecpglib/execute.c
- Starting at line 1005 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/ecpglib/execute.c
- PGTYPESnumeric_free(nval);
- if (!(newcopy = ecpg_realloc(mallocedval, strlen(mallocedval) + slen + 2, lineno)))
- {
- ecpg_free(mallocedval);
- ecpg_free(str);
- return false;
- }
- mallocedval = newcopy;
- /* also copy trailing '\0' */
- memcpy(mallocedval + strlen(mallocedval), str, slen + 1);
- if (var->arrsize > 1)
- strcpy(mallocedval + strlen(mallocedval), ",");
- ecpg_free(str);
- }
- if (var->arrsize > 1)
- strcpy(mallocedval + strlen(mallocedval) - 1, "}");
- *tobeinserted_p = mallocedval;
- }
- break;
- case ECPGt_interval:
- =====================================================================
- Found a 29 line (117 tokens) duplication in the following files:
- Starting at line 451 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/interval.c
- Starting at line 3211 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
- val2 = -val2;
- val = val * MONTHS_PER_YEAR + val2;
- fval = 0;
- }
- else if (*cp == '.')
- {
- errno = 0;
- fval = strtod(cp, &cp);
- if (*cp != '\0' || errno != 0)
- return DTERR_BAD_FORMAT;
- if (*field[i] == '-')
- fval = -fval;
- }
- else if (*cp == '\0')
- fval = 0;
- else
- return DTERR_BAD_FORMAT;
- tmask = 0; /* DTK_M(type); */
- switch (type)
- {
- case DTK_MICROSEC:
- *fsec += rint(val + fval);
- tmask = DTK_M(MICROSECOND);
- break;
- case DTK_MILLISEC:
- =====================================================================
- Found a 9 line (117 tokens) duplication in the following files:
- Starting at line 201 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 216 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 231 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 249 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 274 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 292 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 327 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 404 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 509 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 524 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 539 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 557 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 582 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 600 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
- ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
- #line 70 "cursor.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- =====================================================================
- Found a 15 line (117 tokens) duplication in the following files:
- Starting at line 68 of /home/shackle/pggit/postgresql/src/backend/regex/rege_dfa.c
- Starting at line 197 of /home/shackle/pggit/postgresql/src/backend/regex/rege_dfa.c
- FDEBUG(("+++ startup +++\n"));
- if (cp == v->start)
- {
- co = d->cnfa->bos[(v->eflags & REG_NOTBOL) ? 0 : 1];
- FDEBUG(("color %ld\n", (long) co));
- }
- else
- {
- co = GETCOLOR(cm, *(cp - 1));
- FDEBUG(("char %c, color %ld\n", (char) *(cp - 1), (long) co));
- }
- css = miss(v, d, css, co, cp, start);
- if (css == NULL)
- return NULL;
- css->lastseen = cp;
- =====================================================================
- Found a 36 line (117 tokens) duplication in the following files:
- Starting at line 504 of /home/shackle/pggit/postgresql/src/backend/catalog/dependency.c
- Starting at line 1042 of /home/shackle/pggit/postgresql/src/backend/catalog/dependency.c
- return;
- /*
- * The target object might be internally dependent on some other object
- * (its "owner"), and/or be a member of an extension (also considered its
- * owner). If so, and if we aren't recursing from the owning object, we
- * have to transform this deletion request into a deletion request of the
- * owning object. (We'll eventually recurse back to this object, but the
- * owning object has to be visited first so it will be deleted after.) The
- * way to find out about this is to scan the pg_depend entries that show
- * what this object depends on.
- */
- ScanKeyInit(&key[0],
- Anum_pg_depend_classid,
- BTEqualStrategyNumber, F_OIDEQ,
- ObjectIdGetDatum(object->classId));
- ScanKeyInit(&key[1],
- Anum_pg_depend_objid,
- BTEqualStrategyNumber, F_OIDEQ,
- ObjectIdGetDatum(object->objectId));
- if (object->objectSubId != 0)
- {
- ScanKeyInit(&key[2],
- Anum_pg_depend_objsubid,
- BTEqualStrategyNumber, F_INT4EQ,
- Int32GetDatum(object->objectSubId));
- nkeys = 3;
- }
- else
- nkeys = 2;
- scan = systable_beginscan(*depRel, DependDependerIndexId, true,
- NULL, nkeys, key);
- while (HeapTupleIsValid(tup = systable_getnext(scan)))
- {
- =====================================================================
- Found a 24 line (117 tokens) duplication in the following files:
- Starting at line 1020 of /home/shackle/pggit/postgresql/src/backend/utils/adt/tsvector_op.c
- Starting at line 1102 of /home/shackle/pggit/postgresql/src/backend/utils/adt/tsvector_op.c
- else if (cmp > 0)
- { /* in2 first */
- ptr->haspos = ptr2->haspos;
- ptr->len = ptr2->len;
- memcpy(data + dataoff, data2 + ptr2->pos, ptr2->len);
- ptr->pos = dataoff;
- dataoff += ptr2->len;
- if (ptr->haspos)
- {
- int addlen = add_pos(in2, ptr2, out, ptr, maxpos);
- if (addlen == 0)
- ptr->haspos = 0;
- else
- {
- dataoff = SHORTALIGN(dataoff);
- dataoff += addlen * sizeof(WordEntryPos) + sizeof(uint16);
- }
- }
- ptr++;
- ptr2++;
- i2--;
- }
- =====================================================================
- Found a 28 line (117 tokens) duplication in the following files:
- Starting at line 10447 of /home/shackle/pggit/postgresql/src/backend/commands/tablecmds.c
- Starting at line 12970 of /home/shackle/pggit/postgresql/src/backend/commands/tablecmds.c
- ObjectIdGetDatum(relationOid));
- /* we leave refobjsubid unspecified */
- scan = systable_beginscan(depRel, DependReferenceIndexId, true,
- NULL, 2, key);
- while (HeapTupleIsValid(tup = systable_getnext(scan)))
- {
- Form_pg_depend depForm = (Form_pg_depend) GETSTRUCT(tup);
- Relation seqRel;
- /* skip dependencies other than auto dependencies on columns */
- if (depForm->refobjsubid == 0 ||
- depForm->classid != RelationRelationId ||
- depForm->objsubid != 0 ||
- !(depForm->deptype == DEPENDENCY_AUTO || depForm->deptype == DEPENDENCY_INTERNAL))
- continue;
- /* Use relation_open just in case it's an index */
- seqRel = relation_open(depForm->objid, lockmode);
- /* skip non-sequence relations */
- if (RelationGetForm(seqRel)->relkind != RELKIND_SEQUENCE)
- {
- /* No need to keep the lock */
- relation_close(seqRel, lockmode);
- continue;
- }
- =====================================================================
- Found a 27 line (116 tokens) duplication in the following files:
- Starting at line 2146 of /home/shackle/pggit/postgresql/contrib/dblink/dblink.c
- Starting at line 2263 of /home/shackle/pggit/postgresql/contrib/dblink/dblink.c
- get_sql_insert(Relation rel, int *pkattnums, int pknumatts, char **src_pkattvals, char **tgt_pkattvals)
- {
- char *relname;
- HeapTuple tuple;
- TupleDesc tupdesc;
- int natts;
- StringInfoData buf;
- char *val;
- int key;
- int i;
- bool needComma;
- initStringInfo(&buf);
- /* get relation name including any needed schema prefix and quoting */
- relname = generate_relation_name(rel);
- tupdesc = rel->rd_att;
- natts = tupdesc->natts;
- tuple = get_tuple_of_interest(rel, pkattnums, pknumatts, src_pkattvals);
- if (!tuple)
- ereport(ERROR,
- (errcode(ERRCODE_CARDINALITY_VIOLATION),
- errmsg("source row not found")));
- appendStringInfo(&buf, "INSERT INTO %s(", relname);
- =====================================================================
- Found a 10 line (116 tokens) duplication in the following files:
- Starting at line 52 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_backup_tar.c
- Starting at line 77 of /home/shackle/pggit/postgresql/src/bin/pg_dump/pg_backup_directory.c
- static void _CloseArchive(ArchiveHandle *AH);
- static void _PrintTocData(ArchiveHandle *AH, TocEntry *te);
- static void _WriteExtraToc(ArchiveHandle *AH, TocEntry *te);
- static void _ReadExtraToc(ArchiveHandle *AH, TocEntry *te);
- static void _PrintExtraToc(ArchiveHandle *AH, TocEntry *te);
- static void _StartBlobs(ArchiveHandle *AH, TocEntry *te);
- static void _StartBlob(ArchiveHandle *AH, TocEntry *te, Oid oid);
- static void _EndBlob(ArchiveHandle *AH, TocEntry *te, Oid oid);
- static void _EndBlobs(ArchiveHandle *AH, TocEntry *te);
- =====================================================================
- Found a 5 line (116 tokens) duplication in the following files:
- Starting at line 98 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
- Starting at line 103 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- =====================================================================
- Found a 26 line (116 tokens) duplication in the following files:
- Starting at line 924 of /home/shackle/pggit/postgresql/src/backend/utils/mmgr/mcxt.c
- Starting at line 955 of /home/shackle/pggit/postgresql/src/backend/utils/mmgr/mcxt.c
- palloc(Size size)
- {
- /* duplicates MemoryContextAlloc to avoid increased overhead */
- void *ret;
- MemoryContext context = CurrentMemoryContext;
- AssertArg(MemoryContextIsValid(context));
- AssertNotInCriticalSection(context);
- if (!AllocSizeIsValid(size))
- elog(ERROR, "invalid memory alloc request size %zu", size);
- context->isReset = false;
- ret = context->methods->alloc(context, size);
- if (unlikely(ret == NULL))
- {
- MemoryContextStats(TopMemoryContext);
- ereport(ERROR,
- (errcode(ERRCODE_OUT_OF_MEMORY),
- errmsg("out of memory"),
- errdetail("Failed on request of size %zu in memory context \"%s\".",
- size, context->name)));
- }
- VALGRIND_MEMPOOL_ALLOC(context, ret, size);
- =====================================================================
- Found a 22 line (116 tokens) duplication in the following files:
- Starting at line 704 of /home/shackle/pggit/postgresql/src/backend/jit/llvm/llvmjit_expr.c
- Starting at line 806 of /home/shackle/pggit/postgresql/src/backend/jit/llvm/llvmjit_expr.c
- "b.%d.boolisfalse", i);
- b_boolisanynull = l_bb_before_v(opblocks[i + 1],
- "b.%d.boolisanynull", i);
- b_boolcont = l_bb_before_v(opblocks[i + 1],
- "b.%d.boolcont", i);
- v_boolanynullp = l_ptr_const(op->d.boolexpr.anynull,
- l_ptr(TypeStorageBool));
- v_boolnull = LLVMBuildLoad(b, v_resnullp, "");
- v_boolvalue = LLVMBuildLoad(b, v_resvaluep, "");
- /* set resnull to boolnull */
- LLVMBuildStore(b, v_boolnull, v_resnullp);
- /* set revalue to boolvalue */
- LLVMBuildStore(b, v_boolvalue, v_resvaluep);
- /* check if current input is NULL */
- LLVMBuildCondBr(b,
- LLVMBuildICmp(b, LLVMIntEQ, v_boolnull,
- l_sbool_const(1), ""),
- b_boolisnull,
- =====================================================================
- Found a 27 line (115 tokens) duplication in the following files:
- Starting at line 945 of /home/shackle/pggit/postgresql/src/pl/plpgsql/src/pl_exec.c
- Starting at line 1106 of /home/shackle/pggit/postgresql/src/pl/plpgsql/src/pl_exec.c
- exec_set_found(&estate, false);
- /*
- * Let the instrumentation plugin peek at this function
- */
- if (*plpgsql_plugin_ptr && (*plpgsql_plugin_ptr)->func_beg)
- ((*plpgsql_plugin_ptr)->func_beg) (&estate, func);
- /*
- * Now call the toplevel block of statements
- */
- estate.err_text = NULL;
- estate.err_stmt = (PLpgSQL_stmt *) (func->action);
- rc = exec_stmt_block(&estate, func->action);
- if (rc != PLPGSQL_RC_RETURN)
- {
- estate.err_stmt = NULL;
- estate.err_text = NULL;
- ereport(ERROR,
- (errcode(ERRCODE_S_R_E_FUNCTION_EXECUTED_NO_RETURN_STATEMENT),
- errmsg("control reached end of trigger procedure without RETURN")));
- }
- estate.err_stmt = NULL;
- estate.err_text = gettext_noop("during function exit");
- if (estate.retisset)
- =====================================================================
- Found a 29 line (115 tokens) duplication in the following files:
- Starting at line 698 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/interval.c
- Starting at line 4161 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
- *is_zero = false;
- return cp + strlen(cp);
- }
- /* copy&pasted from .../src/backend/utils/adt/datetime.c */
- static char *
- AddPostgresIntPart(char *cp, int value, const char *units,
- bool *is_zero, bool *is_before)
- {
- if (value == 0)
- return cp;
- sprintf(cp, "%s%s%d %s%s",
- (!*is_zero) ? " " : "",
- (*is_before && value > 0) ? "+" : "",
- value,
- units,
- (value != 1) ? "s" : "");
- /*
- * Each nonzero field sets is_before for (only) the next one. This is a
- * tad bizarre but it's how it worked before...
- */
- *is_before = (value < 0);
- *is_zero = false;
- return cp + strlen(cp);
- }
- /* copy&pasted from .../src/backend/utils/adt/datetime.c */
- static char *
- =====================================================================
- Found a 20 line (115 tokens) duplication in the following files:
- Starting at line 195 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-array_of_struct.c
- Starting at line 199 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-pointer_to_struct.c
- ECPGt_short,&(inds->phone_ind),(long)1,(long)10,sizeof( struct ind ), ECPGt_EORT);
- #line 64 "array_of_struct.pgc"
- if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint();
- #line 64 "array_of_struct.pgc"
- if (sqlca.sqlwarn[0] == 'W') sqlprint();
- #line 64 "array_of_struct.pgc"
- if (sqlca.sqlcode < 0) sqlprint();}
- #line 64 "array_of_struct.pgc"
- printf("\ncusts2:\n");
- for (r = 0; r < 2; r++)
- {
- printf( "name - %s\n", custs2[r].name.arr );
- printf( "phone - %d\n", custs2[r].phone );
- }
- { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select * from customers limit 2", ECPGt_EOIT,
- =====================================================================
- Found a 11 line (115 tokens) duplication in the following files:
- Starting at line 2410 of /home/shackle/pggit/postgresql/src/backend/nodes/outfuncs.c
- Starting at line 3638 of /home/shackle/pggit/postgresql/src/backend/nodes/outfuncs.c
- WRITE_UINT_FIELD(ref_relid);
- WRITE_INT_FIELD(nkeys);
- appendStringInfoString(str, " :conkey");
- for (i = 0; i < node->nkeys; i++)
- appendStringInfo(str, " %d", node->conkey[i]);
- appendStringInfoString(str, " :confkey");
- for (i = 0; i < node->nkeys; i++)
- appendStringInfo(str, " %d", node->confkey[i]);
- appendStringInfoString(str, " :conpfeqop");
- for (i = 0; i < node->nkeys; i++)
- appendStringInfo(str, " %u", node->conpfeqop[i]);
- =====================================================================
- Found a 21 line (115 tokens) duplication in the following files:
- Starting at line 221 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c
- Starting at line 645 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c
- *p++ = LC_JISX0212;
- c1 -= 0x74;
- *p++ = ((c1 & 0x3f) << 1) + 0xf3 + (c2 > 0x9e);
- *p++ = c2 + ((c2 > 0x9e) ? 2 : 0x60) + (c2 < 0x80);
- }
- else if (k >= 0xfa40)
- {
- /*
- * mapping IBM kanji to X0208 and X0212
- */
- for (i = 0;; i++)
- {
- k2 = ibmkanji[i].sjis;
- if (k2 == 0xffff)
- break;
- if (k2 == k)
- {
- k = ibmkanji[i].euc;
- if (k >= 0x8f0000)
- {
- *p++ = LC_JISX0212;
- =====================================================================
- Found a 10 line (115 tokens) duplication in the following files:
- Starting at line 1737 of /home/shackle/pggit/postgresql/src/backend/utils/mb/wchar.c
- Starting at line 1756 of /home/shackle/pggit/postgresql/src/backend/utils/mb/wchar.c
- {pg_mule2wchar_with_len, pg_wchar2mule_with_len, pg_mule_mblen, pg_mule_dsplen, pg_mule_verifier, 4}, /* PG_MULE_INTERNAL */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN1 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN2 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN3 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN4 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN5 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN6 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN7 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN8 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN9 */
- =====================================================================
- Found a 5 line (114 tokens) duplication in the following files:
- Starting at line 83 of /home/shackle/pggit/postgresql/contrib/pgcrypto/crypt-des.c
- Starting at line 358 of /home/shackle/pggit/postgresql/src/port/crypt.c
- static uint8 key_perm[56] = {
- 57, 49, 41, 33, 25, 17, 9, 1, 58, 50, 42, 34, 26, 18,
- 10, 2, 59, 51, 43, 35, 27, 19, 11, 3, 60, 52, 44, 36,
- 63, 55, 47, 39, 31, 23, 15, 7, 62, 54, 46, 38, 30, 22,
- 14, 6, 61, 53, 45, 37, 29, 21, 13, 5, 28, 20, 12, 4
- =====================================================================
- Found a 22 line (114 tokens) duplication in the following files:
- Starting at line 82 of /home/shackle/pggit/postgresql/src/bin/scripts/vacuumdb.c
- Starting at line 25 of /home/shackle/pggit/postgresql/src/bin/scripts/clusterdb.c
- static void init_slot(ParallelSlot *slot, PGconn *conn);
- static void help(const char *progname);
- /* For analyze-in-stages mode */
- #define ANALYZE_NO_STAGE -1
- #define ANALYZE_NUM_STAGES 3
- int
- main(int argc, char *argv[])
- {
- static struct option long_options[] = {
- {"host", required_argument, NULL, 'h'},
- {"port", required_argument, NULL, 'p'},
- {"username", required_argument, NULL, 'U'},
- {"no-password", no_argument, NULL, 'w'},
- {"password", no_argument, NULL, 'W'},
- {"echo", no_argument, NULL, 'e'},
- {"quiet", no_argument, NULL, 'q'},
- {"dbname", required_argument, NULL, 'd'},
- {"analyze", no_argument, NULL, 'z'},
- =====================================================================
- Found a 3 line (114 tokens) duplication in the following files:
- Starting at line 31 of /home/shackle/pggit/postgresql/src/common/base64.c
- Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
- Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 207 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
- =====================================================================
- Found a 3 line (114 tokens) duplication in the following files:
- Starting at line 31 of /home/shackle/pggit/postgresql/src/common/base64.c
- Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
- Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 207 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
- =====================================================================
- Found a 130 line (114 tokens) duplication in the following files:
- Starting at line 14 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/thread-prep.c
- Starting at line 14 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/thread-alloc.c
- int
- main(void)
- {
- printf("No threading enabled.\n");
- return 0;
- }
- #else
- #ifdef WIN32
- #define WIN32_LEAN_AND_MEAN
- #include <windows.h>
- #include <process.h>
- #include <locale.h>
- #else
- #include <pthread.h>
- #endif
- #include <stdio.h>
- #define THREADS 16
- #define REPEATS 50
- #line 1 "sqlca.h"
- #ifndef POSTGRES_SQLCA_H
- #define POSTGRES_SQLCA_H
- #ifndef PGDLLIMPORT
- #if defined(WIN32) || defined(__CYGWIN__)
- #define PGDLLIMPORT __declspec (dllimport)
- #else
- #define PGDLLIMPORT
- #endif /* __CYGWIN__ */
- #endif /* PGDLLIMPORT */
- #define SQLERRMC_LEN 150
- #ifdef __cplusplus
- extern "C"
- {
- #endif
- struct sqlca_t
- {
- char sqlcaid[8];
- long sqlabc;
- long sqlcode;
- struct
- {
- int sqlerrml;
- char sqlerrmc[SQLERRMC_LEN];
- } sqlerrm;
- char sqlerrp[8];
- long sqlerrd[6];
- /* Element 0: empty */
- /* 1: OID of processed tuple if applicable */
- /* 2: number of rows processed */
- /* after an INSERT, UPDATE or */
- /* DELETE statement */
- /* 3: empty */
- /* 4: empty */
- /* 5: empty */
- char sqlwarn[8];
- /* Element 0: set to 'W' if at least one other is 'W' */
- /* 1: if 'W' at least one character string */
- /* value was truncated when it was */
- /* stored into a host variable. */
- /*
- * 2: if 'W' a (hopefully) non-fatal notice occurred
- */ /* 3: empty */
- /* 4: empty */
- /* 5: empty */
- /* 6: empty */
- /* 7: empty */
- char sqlstate[5];
- };
- struct sqlca_t *ECPGget_sqlca(void);
- #ifndef POSTGRES_ECPG_INTERNAL
- #define sqlca (*ECPGget_sqlca())
- #endif
- #ifdef __cplusplus
- }
- #endif
- #endif
- #line 25 "prep.pgc"
- #line 1 "regression.h"
- #line 26 "prep.pgc"
- /* exec sql whenever sqlerror sqlprint ; */
- #line 28 "prep.pgc"
- /* exec sql whenever not found sqlprint ; */
- #line 29 "prep.pgc"
- #ifdef WIN32
- static unsigned __stdcall fn(void* arg)
- #else
- static void* fn(void* arg)
- #endif
- {
- int i;
- /* exec sql begin declare section */
- #line 40 "prep.pgc"
- int value ;
- #line 41 "prep.pgc"
- char name [ 100 ] ;
- #line 42 "prep.pgc"
- char query [ 256 ] = "INSERT INTO T VALUES ( ? )" ;
- =====================================================================
- Found a 5 line (114 tokens) duplication in the following files:
- Starting at line 98 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
- Starting at line 103 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- =====================================================================
- Found a 26 line (114 tokens) duplication in the following files:
- Starting at line 450 of /home/shackle/pggit/postgresql/src/backend/catalog/pg_subscription.c
- Starting at line 502 of /home/shackle/pggit/postgresql/src/backend/catalog/pg_subscription.c
- ObjectIdGetDatum(subid));
- scan = systable_beginscan(rel, InvalidOid, false,
- NULL, nkeys, skey);
- while (HeapTupleIsValid(tup = systable_getnext(scan)))
- {
- Form_pg_subscription_rel subrel;
- SubscriptionRelState *relstate;
- subrel = (Form_pg_subscription_rel) GETSTRUCT(tup);
- relstate = (SubscriptionRelState *) palloc(sizeof(SubscriptionRelState));
- relstate->relid = subrel->srrelid;
- relstate->state = subrel->srsubstate;
- relstate->lsn = subrel->srsublsn;
- res = lappend(res, relstate);
- }
- /* Cleanup */
- systable_endscan(scan);
- heap_close(rel, AccessShareLock);
- return res;
- }
- =====================================================================
- Found a 49 line (114 tokens) duplication in the following files:
- Starting at line 1084 of /home/shackle/pggit/postgresql/src/backend/utils/mmgr/aset.c
- Starting at line 552 of /home/shackle/pggit/postgresql/src/backend/utils/mmgr/generation.c
- set->header.name, chunk);
- #endif
- /*
- * Chunk sizes are aligned to power of 2 in AllocSetAlloc(). Maybe the
- * allocated area already is >= the new size. (In particular, we always
- * fall out here if the requested size is a decrease.)
- */
- if (oldsize >= size)
- {
- #ifdef MEMORY_CONTEXT_CHECKING
- Size oldrequest = chunk->requested_size;
- #ifdef RANDOMIZE_ALLOCATED_MEMORY
- /* We can only fill the extra space if we know the prior request */
- if (size > oldrequest)
- randomize_mem((char *) pointer + oldrequest,
- size - oldrequest);
- #endif
- chunk->requested_size = size;
- /*
- * If this is an increase, mark any newly-available part UNDEFINED.
- * Otherwise, mark the obsolete part NOACCESS.
- */
- if (size > oldrequest)
- VALGRIND_MAKE_MEM_UNDEFINED((char *) pointer + oldrequest,
- size - oldrequest);
- else
- VALGRIND_MAKE_MEM_NOACCESS((char *) pointer + size,
- oldsize - size);
- /* set mark to catch clobber of "unused" space */
- if (size < oldsize)
- set_sentinel(pointer, size);
- #else /* !MEMORY_CONTEXT_CHECKING */
- /*
- * We don't have the information to determine whether we're growing
- * the old request or shrinking it, so we conservatively mark the
- * entire new allocation DEFINED.
- */
- VALGRIND_MAKE_MEM_NOACCESS(pointer, oldsize);
- VALGRIND_MAKE_MEM_DEFINED(pointer, size);
- #endif
- /* Disallow external access to private part of chunk header. */
- VALGRIND_MAKE_MEM_NOACCESS(chunk, ALLOCCHUNK_PRIVATE_LEN);
- =====================================================================
- Found a 31 line (114 tokens) duplication in the following files:
- Starting at line 771 of /home/shackle/pggit/postgresql/src/backend/utils/mmgr/mcxt.c
- Starting at line 814 of /home/shackle/pggit/postgresql/src/backend/utils/mmgr/mcxt.c
- Starting at line 852 of /home/shackle/pggit/postgresql/src/backend/utils/mmgr/mcxt.c
- MemoryContextAlloc(MemoryContext context, Size size)
- {
- void *ret;
- AssertArg(MemoryContextIsValid(context));
- AssertNotInCriticalSection(context);
- if (!AllocSizeIsValid(size))
- elog(ERROR, "invalid memory alloc request size %zu", size);
- context->isReset = false;
- ret = context->methods->alloc(context, size);
- if (unlikely(ret == NULL))
- {
- MemoryContextStats(TopMemoryContext);
- /*
- * Here, and elsewhere in this module, we show the target context's
- * "name" but not its "ident" (if any) in user-visible error messages.
- * The "ident" string might contain security-sensitive data, such as
- * values in SQL commands.
- */
- ereport(ERROR,
- (errcode(ERRCODE_OUT_OF_MEMORY),
- errmsg("out of memory"),
- errdetail("Failed on request of size %zu in memory context \"%s\".",
- size, context->name)));
- }
- VALGRIND_MEMPOOL_ALLOC(context, ret, size);
- =====================================================================
- Found a 16 line (114 tokens) duplication in the following files:
- Starting at line 902 of /home/shackle/pggit/postgresql/src/backend/utils/adt/numeric.c
- Starting at line 555 of /home/shackle/pggit/postgresql/src/backend/utils/adt/varchar.c
- numeric_transform(PG_FUNCTION_ARGS)
- {
- FuncExpr *expr = castNode(FuncExpr, PG_GETARG_POINTER(0));
- Node *ret = NULL;
- Node *typmod;
- Assert(list_length(expr->args) >= 2);
- typmod = (Node *) lsecond(expr->args);
- if (IsA(typmod, Const) &&!((Const *) typmod)->constisnull)
- {
- Node *source = (Node *) linitial(expr->args);
- int32 old_typmod = exprTypmod(source);
- int32 new_typmod = DatumGetInt32(((Const *) typmod)->constvalue);
- int32 old_scale = (old_typmod - VARHDRSZ) & 0xffff;
- =====================================================================
- Found a 22 line (114 tokens) duplication in the following files:
- Starting at line 5361 of /home/shackle/pggit/postgresql/src/backend/access/transam/xact.c
- Starting at line 5496 of /home/shackle/pggit/postgresql/src/backend/access/transam/xact.c
- XLogRegisterData((char *) (&xl_xinfo.xinfo), sizeof(xl_xinfo.xinfo));
- if (xl_xinfo.xinfo & XACT_XINFO_HAS_DBINFO)
- XLogRegisterData((char *) (&xl_dbinfo), sizeof(xl_dbinfo));
- if (xl_xinfo.xinfo & XACT_XINFO_HAS_SUBXACTS)
- {
- XLogRegisterData((char *) (&xl_subxacts),
- MinSizeOfXactSubxacts);
- XLogRegisterData((char *) subxacts,
- nsubxacts * sizeof(TransactionId));
- }
- if (xl_xinfo.xinfo & XACT_XINFO_HAS_RELFILENODES)
- {
- XLogRegisterData((char *) (&xl_relfilenodes),
- MinSizeOfXactRelfilenodes);
- XLogRegisterData((char *) rels,
- nrels * sizeof(RelFileNode));
- }
- if (xl_xinfo.xinfo & XACT_XINFO_HAS_INVALS)
- =====================================================================
- Found a 26 line (114 tokens) duplication in the following files:
- Starting at line 486 of /home/shackle/pggit/postgresql/src/backend/access/hash/hashfunc.c
- Starting at line 586 of /home/shackle/pggit/postgresql/src/backend/access/hash/hashfunc.c
- Starting at line 726 of /home/shackle/pggit/postgresql/src/backend/access/hash/hashfunc.c
- Starting at line 826 of /home/shackle/pggit/postgresql/src/backend/access/hash/hashfunc.c
- break;
- case 3:
- a += ((uint32) k[2] << 8);
- /* fall through */
- case 2:
- a += ((uint32) k[1] << 16);
- /* fall through */
- case 1:
- a += ((uint32) k[0] << 24);
- /* case 0: nothing left to add */
- }
- #else /* !WORDS_BIGENDIAN */
- switch (len)
- {
- case 11:
- c += ((uint32) k[10] << 24);
- /* fall through */
- case 10:
- c += ((uint32) k[9] << 16);
- /* fall through */
- case 9:
- c += ((uint32) k[8] << 8);
- /* fall through */
- case 8:
- /* the lowest byte of c is reserved for the length */
- b += ka[1];
- =====================================================================
- Found a 22 line (113 tokens) duplication in the following files:
- Starting at line 435 of /home/shackle/pggit/postgresql/contrib/hstore/hstore_gist.c
- Starting at line 375 of /home/shackle/pggit/postgresql/contrib/ltree/_ltree_gist.c
- union_r = GETSIGN(datum_r);
- for (k = 0; k < maxoff; k++)
- {
- j = costvector[k].pos;
- if (j == seed_1)
- {
- *left++ = j;
- v->spl_nleft++;
- continue;
- }
- else if (j == seed_2)
- {
- *right++ = j;
- v->spl_nright++;
- continue;
- }
- _j = GETENTRY(entryvec, j);
- size_alpha = hemdist(datum_l, _j);
- size_beta = hemdist(datum_r, _j);
- if (size_alpha < size_beta + WISH_F(v->spl_nleft, v->spl_nright, 0.0001))
- =====================================================================
- Found a 21 line (113 tokens) duplication in the following files:
- Starting at line 261 of /home/shackle/pggit/postgresql/src/bin/pg_test_fsync/pg_test_fsync.c
- Starting at line 364 of /home/shackle/pggit/postgresql/src/bin/pg_test_fsync/pg_test_fsync.c
- if ((tmpfile = open(filename, O_RDWR | O_DSYNC | PG_O_DIRECT, 0)) == -1)
- {
- printf(NA_FORMAT, _("n/a*"));
- fs_warning = true;
- }
- else
- {
- START_TIMER;
- for (ops = 0; alarm_triggered == false; ops++)
- {
- for (writes = 0; writes < writes_per_op; writes++)
- if (write(tmpfile, buf, XLOG_BLCKSZ) != XLOG_BLCKSZ)
- die("write failed");
- if (lseek(tmpfile, 0, SEEK_SET) == -1)
- die("seek failed");
- }
- STOP_TIMER;
- close(tmpfile);
- }
- #else
- printf(NA_FORMAT, _("n/a"));
- =====================================================================
- Found a 31 line (113 tokens) duplication in the following files:
- Starting at line 143 of /home/shackle/pggit/postgresql/src/include/catalog/pg_aggregate.h
- Starting at line 45 of /home/shackle/pggit/postgresql/src/backend/catalog/pg_aggregate.c
- extern ObjectAddress AggregateCreate(const char *aggName,
- Oid aggNamespace,
- char aggKind,
- int numArgs,
- int numDirectArgs,
- oidvector *parameterTypes,
- Datum allParameterTypes,
- Datum parameterModes,
- Datum parameterNames,
- List *parameterDefaults,
- Oid variadicArgType,
- List *aggtransfnName,
- List *aggfinalfnName,
- List *aggcombinefnName,
- List *aggserialfnName,
- List *aggdeserialfnName,
- List *aggmtransfnName,
- List *aggminvtransfnName,
- List *aggmfinalfnName,
- bool finalfnExtraArgs,
- bool mfinalfnExtraArgs,
- char finalfnModify,
- char mfinalfnModify,
- List *aggsortopName,
- Oid aggTransType,
- int32 aggTransSpace,
- Oid aggmTransType,
- int32 aggmTransSpace,
- const char *agginitval,
- const char *aggminitval,
- char proparallel);
- =====================================================================
- Found a 16 line (113 tokens) duplication in the following files:
- Starting at line 193 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/thread-thread_implicit.c
- Starting at line 192 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/thread-thread.c
- { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test_thread ( thread , iteration ) values ( $1 , $2 )",
- ECPGt_char,(l_connection),(long)128,(long)1,(128)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_int,&(l_i),(long)1,(long)1,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
- #line 132 "thread_implicit.pgc"
- if (sqlca.sqlcode < 0) sqlprint();}
- #line 132 "thread_implicit.pgc"
- if( sqlca.sqlcode != 0 )
- printf("%s: ERROR: insert failed!\n", l_connection);
- }
- /* all done */
- { ECPGtrans(__LINE__, NULL, "commit");
- =====================================================================
- Found a 38 line (113 tokens) duplication in the following files:
- Starting at line 36 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/compat_informix-dec_test.c
- Starting at line 33 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/pgtypeslib-num_test2.c
- static void
- print_double(double x)
- {
- #ifdef WIN32
- /* Change Windows' 3-digit exponents to look like everyone else's */
- char convert[128];
- int vallen;
- sprintf(convert, "%g", x);
- vallen = strlen(convert);
- if (vallen >= 6 &&
- convert[vallen - 5] == 'e' &&
- convert[vallen - 3] == '0')
- {
- convert[vallen - 3] = convert[vallen - 2];
- convert[vallen - 2] = convert[vallen - 1];
- convert[vallen - 1] = '\0';
- }
- printf("%s", convert);
- #else
- printf("%g", x);
- #endif
- }
- #line 10 "dec_test.pgc"
- /*
- TODO:
- deccmp => DECUNKNOWN
- decimal point: , and/or . ?
- ECPG_INFORMIX_BAD_EXPONENT ?
- */
- char* decs[] = { "2E394", "-2", ".794", "3.44", "592.49E21", "-32.84e4",
- =====================================================================
- Found a 28 line (113 tokens) duplication in the following files:
- Starting at line 213 of /home/shackle/pggit/postgresql/src/backend/utils/mb/wchar.c
- Starting at line 281 of /home/shackle/pggit/postgresql/src/backend/utils/mb/wchar.c
- len -= 3;
- }
- else if (*from == SS3 && len >= 3) /* code set 3 (unused ?) */
- {
- from++;
- *to = (SS3 << 16) | (*from++ << 8);
- *to |= *from++;
- len -= 3;
- }
- else if (IS_HIGHBIT_SET(*from) && len >= 2) /* code set 1 */
- {
- *to = *from++ << 8;
- *to |= *from++;
- len -= 2;
- }
- else
- {
- *to = *from++;
- len--;
- }
- to++;
- cnt++;
- }
- *to = 0;
- return cnt;
- }
- static int
- =====================================================================
- Found a 18 line (113 tokens) duplication in the following files:
- Starting at line 4821 of /home/shackle/pggit/postgresql/src/backend/utils/adt/jsonfuncs.c
- Starting at line 4934 of /home/shackle/pggit/postgresql/src/backend/utils/adt/jsonfuncs.c
- r = JsonbIteratorNext(it, &v, false);
- (void) pushJsonbValue(st, r, r < WJB_BEGIN_ARRAY ? &v : NULL);
- if (r == WJB_BEGIN_ARRAY || r == WJB_BEGIN_OBJECT)
- {
- int walking_level = 1;
- while (walking_level != 0)
- {
- r = JsonbIteratorNext(it, &v, false);
- if (r == WJB_BEGIN_ARRAY || r == WJB_BEGIN_OBJECT)
- ++walking_level;
- if (r == WJB_END_ARRAY || r == WJB_END_OBJECT)
- --walking_level;
- (void) pushJsonbValue(st, r, r < WJB_BEGIN_ARRAY ? &v : NULL);
- }
- }
- =====================================================================
- Found a 40 line (113 tokens) duplication in the following files:
- Starting at line 2163 of /home/shackle/pggit/postgresql/src/backend/utils/adt/float.c
- Starting at line 2282 of /home/shackle/pggit/postgresql/src/backend/utils/adt/float.c
- volatile float8 cot_arg1;
- int sign = 1;
- /*
- * Per the POSIX spec, return NaN if the input is NaN and throw an error
- * if the input is infinite.
- */
- if (isnan(arg1))
- PG_RETURN_FLOAT8(get_float8_nan());
- if (isinf(arg1))
- ereport(ERROR,
- (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
- errmsg("input is out of range")));
- INIT_DEGREE_CONSTANTS();
- /* Reduce the range of the input to [0,90] degrees */
- arg1 = fmod(arg1, 360.0);
- if (arg1 < 0.0)
- {
- /* cotd(-x) = -cotd(x) */
- arg1 = -arg1;
- sign = -sign;
- }
- if (arg1 > 180.0)
- {
- /* cotd(360-x) = -cotd(x) */
- arg1 = 360.0 - arg1;
- sign = -sign;
- }
- if (arg1 > 90.0)
- {
- /* cotd(180-x) = -cotd(x) */
- arg1 = 180.0 - arg1;
- sign = -sign;
- }
- =====================================================================
- Found a 26 line (113 tokens) duplication in the following files:
- Starting at line 747 of /home/shackle/pggit/postgresql/src/backend/jit/llvm/llvmjit_expr.c
- Starting at line 848 of /home/shackle/pggit/postgresql/src/backend/jit/llvm/llvmjit_expr.c
- LLVMPositionBuilderAtEnd(b, b_boolisfalse);
- /* result is already set to FALSE, need not change it */
- /* and jump to the end of the AND expression */
- LLVMBuildBr(b, opblocks[op->d.boolexpr.jumpdone]);
- /* Build block that continues if bool is TRUE. */
- LLVMPositionBuilderAtEnd(b, b_boolcont);
- v_boolanynull = LLVMBuildLoad(b, v_boolanynullp, "");
- /* set value to NULL if any previous values were NULL */
- LLVMBuildCondBr(b,
- LLVMBuildICmp(b, LLVMIntEQ, v_boolanynull,
- l_sbool_const(0), ""),
- opblocks[i + 1], b_boolisanynull);
- LLVMPositionBuilderAtEnd(b, b_boolisanynull);
- /* set resnull to true */
- LLVMBuildStore(b, l_sbool_const(1), v_resnullp);
- /* reset resvalue */
- LLVMBuildStore(b, l_sizet_const(0), v_resvaluep);
- LLVMBuildBr(b, opblocks[i + 1]);
- break;
- }
- case EEOP_BOOL_OR_STEP_FIRST:
- =====================================================================
- Found a 25 line (112 tokens) duplication in the following files:
- Starting at line 126 of /home/shackle/pggit/postgresql/src/test/examples/testlo64.c
- Starting at line 120 of /home/shackle/pggit/postgresql/src/test/examples/testlo.c
- fprintf(stderr, "error in lo_lseek64: %s", PQerrorMessage(conn));
- buf = malloc(len + 1);
- for (i = 0; i < len; i++)
- buf[i] = 'X';
- buf[i] = '\0';
- nwritten = 0;
- while (len - nwritten > 0)
- {
- nbytes = lo_write(conn, lobj_fd, buf + nwritten, len - nwritten);
- nwritten += nbytes;
- if (nbytes <= 0)
- {
- fprintf(stderr, "\nWRITE FAILED!\n");
- break;
- }
- }
- free(buf);
- fprintf(stderr, "\n");
- lo_close(conn, lobj_fd);
- }
- static void
- =====================================================================
- Found a 24 line (112 tokens) duplication in the following files:
- Starting at line 1994 of /home/shackle/pggit/postgresql/src/backend/optimizer/plan/setrefs.c
- Starting at line 2044 of /home/shackle/pggit/postgresql/src/backend/optimizer/plan/setrefs.c
- build_tlist_index(List *tlist)
- {
- indexed_tlist *itlist;
- tlist_vinfo *vinfo;
- ListCell *l;
- /* Create data structure with enough slots for all tlist entries */
- itlist = (indexed_tlist *)
- palloc(offsetof(indexed_tlist, vars) +
- list_length(tlist) * sizeof(tlist_vinfo));
- itlist->tlist = tlist;
- itlist->has_ph_vars = false;
- itlist->has_non_vars = false;
- /* Find the Vars and fill in the index array */
- vinfo = itlist->vars;
- foreach(l, tlist)
- {
- TargetEntry *tle = (TargetEntry *) lfirst(l);
- if (tle->expr && IsA(tle->expr, Var))
- {
- Var *var = (Var *) tle->expr;
- =====================================================================
- Found a 22 line (112 tokens) duplication in the following files:
- Starting at line 336 of /home/shackle/pggit/postgresql/src/backend/storage/buffer/localbuf.c
- Starting at line 380 of /home/shackle/pggit/postgresql/src/backend/storage/buffer/localbuf.c
- bufHdr->tag.blockNum >= firstDelBlock)
- {
- if (LocalRefCount[i] != 0)
- elog(ERROR, "block %u of %s is still referenced (local %u)",
- bufHdr->tag.blockNum,
- relpathbackend(bufHdr->tag.rnode, MyBackendId,
- bufHdr->tag.forkNum),
- LocalRefCount[i]);
- /* Remove entry from hashtable */
- hresult = (LocalBufferLookupEnt *)
- hash_search(LocalBufHash, (void *) &bufHdr->tag,
- HASH_REMOVE, NULL);
- if (!hresult) /* shouldn't happen */
- elog(ERROR, "local buffer hash table corrupted");
- /* Mark buffer invalid */
- CLEAR_BUFFERTAG(bufHdr->tag);
- buf_state &= ~BUF_FLAG_MASK;
- buf_state &= ~BUF_USAGECOUNT_MASK;
- pg_atomic_unlocked_write_u32(&bufHdr->state, buf_state);
- }
- }
- }
- =====================================================================
- Found a 27 line (112 tokens) duplication in the following files:
- Starting at line 240 of /home/shackle/pggit/postgresql/src/backend/executor/nodeWindowAgg.c
- Starting at line 417 of /home/shackle/pggit/postgresql/src/backend/executor/nodeWindowAgg.c
- advance_windowaggregate(WindowAggState *winstate,
- WindowStatePerFunc perfuncstate,
- WindowStatePerAgg peraggstate)
- {
- WindowFuncExprState *wfuncstate = perfuncstate->wfuncstate;
- int numArguments = perfuncstate->numArguments;
- FunctionCallInfoData fcinfodata;
- FunctionCallInfo fcinfo = &fcinfodata;
- Datum newVal;
- ListCell *arg;
- int i;
- MemoryContext oldContext;
- ExprContext *econtext = winstate->tmpcontext;
- ExprState *filter = wfuncstate->aggfilter;
- oldContext = MemoryContextSwitchTo(econtext->ecxt_per_tuple_memory);
- /* Skip anything FILTERed out */
- if (filter)
- {
- bool isnull;
- Datum res = ExecEvalExpr(filter, econtext, &isnull);
- if (isnull || !DatumGetBool(res))
- {
- MemoryContextSwitchTo(oldContext);
- return;
- =====================================================================
- Found a 5 line (112 tokens) duplication in the following files:
- Starting at line 98 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
- Starting at line 103 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- =====================================================================
- Found a 12 line (112 tokens) duplication in the following files:
- Starting at line 303 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c
- Starting at line 538 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c
- c2 = mic[2];
- k = (c1 << 8) | (c2 & 0xff);
- if (k >= 0xf5a1)
- {
- /* UDC1 */
- c1 -= 0x54;
- *p++ = ((c1 - 0xa1) >> 1) + ((c1 < 0xdf) ? 0x81 : 0xc1) + 0x6f;
- }
- else
- *p++ = ((c1 - 0xa1) >> 1) + ((c1 < 0xdf) ? 0x81 : 0xc1);
- *p++ = c2 - ((c1 & 1) ? ((c2 < 0xe0) ? 0x61 : 0x60) : 2);
- }
- =====================================================================
- Found a 28 line (112 tokens) duplication in the following files:
- Starting at line 86 of /home/shackle/pggit/postgresql/src/backend/utils/mb/wchar.c
- Starting at line 213 of /home/shackle/pggit/postgresql/src/backend/utils/mb/wchar.c
- Starting at line 281 of /home/shackle/pggit/postgresql/src/backend/utils/mb/wchar.c
- len -= 2;
- }
- else if (*from == SS3 && len >= 3) /* JIS X 0212 KANJI */
- {
- from++;
- *to = (SS3 << 16) | (*from++ << 8);
- *to |= *from++;
- len -= 3;
- }
- else if (IS_HIGHBIT_SET(*from) && len >= 2) /* JIS X 0208 KANJI */
- {
- *to = *from++ << 8;
- *to |= *from++;
- len -= 2;
- }
- else /* must be ASCII */
- {
- *to = *from++;
- len--;
- }
- to++;
- cnt++;
- }
- *to = 0;
- return cnt;
- }
- static inline int
- =====================================================================
- Found a 38 line (111 tokens) duplication in the following files:
- Starting at line 972 of /home/shackle/pggit/postgresql/contrib/postgres_fdw/postgres_fdw.c
- Starting at line 1048 of /home/shackle/pggit/postgresql/contrib/postgres_fdw/postgres_fdw.c
- foreach(lc, baserel->joininfo)
- {
- RestrictInfo *rinfo = (RestrictInfo *) lfirst(lc);
- Relids required_outer;
- ParamPathInfo *param_info;
- /* Check if clause can be moved to this rel */
- if (!join_clause_is_movable_to(rinfo, baserel))
- continue;
- /* See if it is safe to send to remote */
- if (!is_foreign_expr(root, baserel, rinfo->clause))
- continue;
- /* Calculate required outer rels for the resulting path */
- required_outer = bms_union(rinfo->clause_relids,
- baserel->lateral_relids);
- /* We do not want the foreign rel itself listed in required_outer */
- required_outer = bms_del_member(required_outer, baserel->relid);
- /*
- * required_outer probably can't be empty here, but if it were, we
- * couldn't make a parameterized path.
- */
- if (bms_is_empty(required_outer))
- continue;
- /* Get the ParamPathInfo */
- param_info = get_baserel_parampathinfo(root, baserel,
- required_outer);
- Assert(param_info != NULL);
- /*
- * Add it to list unless we already have it. Testing pointer equality
- * is OK since get_baserel_parampathinfo won't make duplicates.
- */
- ppi_list = list_append_unique_ptr(ppi_list, param_info);
- }
- =====================================================================
- Found a 34 line (111 tokens) duplication in the following files:
- Starting at line 5419 of /home/shackle/pggit/postgresql/src/pl/plpgsql/src/pl_exec.c
- Starting at line 6513 of /home/shackle/pggit/postgresql/src/pl/plpgsql/src/pl_exec.c
- ExpandedRecordHeader *erh;
- rec = (PLpgSQL_rec *) (estate->datums[recfield->recparentno]);
- erh = rec->erh;
- /*
- * If record variable is NULL, instantiate it if it has a
- * named composite type, else complain. (This won't change
- * the logical state of the record: it's still NULL.)
- */
- if (erh == NULL)
- {
- instantiate_empty_record_variable(estate, rec);
- erh = rec->erh;
- }
- /*
- * Look up the field's properties if we have not already, or
- * if the tuple descriptor ID changed since last time.
- */
- if (unlikely(recfield->rectupledescid != erh->er_tupdesc_id))
- {
- if (!expanded_record_lookup_field(erh,
- recfield->fieldname,
- &recfield->finfo))
- ereport(ERROR,
- (errcode(ERRCODE_UNDEFINED_COLUMN),
- errmsg("record \"%s\" has no field \"%s\"",
- rec->refname, recfield->fieldname)));
- recfield->rectupledescid = erh->er_tupdesc_id;
- }
- /* Report type data. */
- *typeid = recfield->finfo.ftypeid;
- =====================================================================
- Found a 3 line (111 tokens) duplication in the following files:
- Starting at line 31 of /home/shackle/pggit/postgresql/src/common/base64.c
- Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
- Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 207 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
- =====================================================================
- Found a 3 line (111 tokens) duplication in the following files:
- Starting at line 31 of /home/shackle/pggit/postgresql/src/common/base64.c
- Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
- Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 207 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
- =====================================================================
- Found a 25 line (111 tokens) duplication in the following files:
- Starting at line 32 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/pgtypeslib-num_test.c
- Starting at line 36 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/compat_informix-dec_test.c
- Starting at line 33 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/pgtypeslib-num_test2.c
- Starting at line 5 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/printf_hack.h
- static void
- print_double(double x)
- {
- #ifdef WIN32
- /* Change Windows' 3-digit exponents to look like everyone else's */
- char convert[128];
- int vallen;
- sprintf(convert, "%g", x);
- vallen = strlen(convert);
- if (vallen >= 6 &&
- convert[vallen - 5] == 'e' &&
- convert[vallen - 3] == '0')
- {
- convert[vallen - 3] = convert[vallen - 2];
- convert[vallen - 2] = convert[vallen - 1];
- convert[vallen - 1] = '\0';
- }
- printf("%s", convert);
- #else
- printf("%g", x);
- #endif
- }
- =====================================================================
- Found a 14 line (111 tokens) duplication in the following files:
- Starting at line 201 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 341 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 694 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 709 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 727 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 752 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 770 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
- ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
- #line 70 "cursor.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 70 "cursor.pgc"
- printf("%d %s\n", id, t);
- strcpy(msg, "fetch");
- =====================================================================
- Found a 14 line (111 tokens) duplication in the following files:
- Starting at line 216 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 231 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 249 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 274 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 292 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 356 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 371 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 389 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 418 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 436 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 509 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 524 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 539 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 557 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 582 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 600 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- Starting at line 679 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/preproc-cursor.c
- ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
- ECPGt_int,&(id),(long)1,(long)1,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
- #line 74 "cursor.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 74 "cursor.pgc"
- printf("%d %s\n", id, t);
- strcpy(msg, "fetch 1 from");
- =====================================================================
- Found a 36 line (111 tokens) duplication in the following files:
- Starting at line 482 of /home/shackle/pggit/postgresql/src/backend/utils/adt/int8.c
- Starting at line 650 of /home/shackle/pggit/postgresql/src/backend/utils/adt/int.c
- int64 base = PG_GETARG_INT64(1);
- int64 offset = PG_GETARG_INT64(2);
- bool sub = PG_GETARG_BOOL(3);
- bool less = PG_GETARG_BOOL(4);
- int64 sum;
- if (offset < 0)
- ereport(ERROR,
- (errcode(ERRCODE_INVALID_PRECEDING_OR_FOLLOWING_SIZE),
- errmsg("invalid preceding or following size in window function")));
- if (sub)
- offset = -offset; /* cannot overflow */
- if (unlikely(pg_add_s64_overflow(base, offset, &sum)))
- {
- /*
- * If sub is false, the true sum is surely more than val, so correct
- * answer is the same as "less". If sub is true, the true sum is
- * surely less than val, so the answer is "!less".
- */
- PG_RETURN_BOOL(sub ? !less : less);
- }
- if (less)
- PG_RETURN_BOOL(val <= sum);
- else
- PG_RETURN_BOOL(val >= sum);
- }
- /*----------------------------------------------------------
- * Arithmetic operators on 64-bit integers.
- *---------------------------------------------------------*/
- Datum
- =====================================================================
- Found a 22 line (111 tokens) duplication in the following files:
- Starting at line 558 of /home/shackle/pggit/postgresql/src/backend/utils/adt/jsonfuncs.c
- Starting at line 622 of /home/shackle/pggit/postgresql/src/backend/utils/adt/jsonfuncs.c
- MemoryContextSwitchTo(oldcontext);
- funcctx->user_fctx = (void *) state;
- }
- funcctx = SRF_PERCALL_SETUP();
- state = (OkeysState *) funcctx->user_fctx;
- if (state->sent_count < state->result_count)
- {
- char *nxt = state->result[state->sent_count++];
- SRF_RETURN_NEXT(funcctx, CStringGetTextDatum(nxt));
- }
- /* cleanup to reduce or eliminate memory leaks */
- for (i = 0; i < state->result_count; i++)
- pfree(state->result[i]);
- pfree(state->result);
- pfree(state);
- SRF_RETURN_DONE(funcctx);
- }
- =====================================================================
- Found a 18 line (111 tokens) duplication in the following files:
- Starting at line 1185 of /home/shackle/pggit/postgresql/src/backend/utils/adt/date.c
- Starting at line 1976 of /home/shackle/pggit/postgresql/src/backend/utils/adt/date.c
- TimeADT result;
- fsec_t fsec;
- struct pg_tm tt,
- *tm = &tt;
- int tz;
- int nf;
- int dterr;
- char workbuf[MAXDATELEN + 1];
- char *field[MAXDATEFIELDS];
- int dtype;
- int ftype[MAXDATEFIELDS];
- dterr = ParseDateTime(str, workbuf, sizeof(workbuf),
- field, ftype, MAXDATEFIELDS, &nf);
- if (dterr == 0)
- dterr = DecodeTimeOnly(field, ftype, nf, &dtype, tm, &fsec, &tz);
- if (dterr != 0)
- DateTimeParseError(dterr, str, "time");
- =====================================================================
- Found a 18 line (111 tokens) duplication in the following files:
- Starting at line 151 of /home/shackle/pggit/postgresql/src/backend/utils/adt/timestamp.c
- Starting at line 391 of /home/shackle/pggit/postgresql/src/backend/utils/adt/timestamp.c
- Timestamp result;
- fsec_t fsec;
- struct pg_tm tt,
- *tm = &tt;
- int tz;
- int dtype;
- int nf;
- int dterr;
- char *field[MAXDATEFIELDS];
- int ftype[MAXDATEFIELDS];
- char workbuf[MAXDATELEN + MAXDATEFIELDS];
- dterr = ParseDateTime(str, workbuf, sizeof(workbuf),
- field, ftype, MAXDATEFIELDS, &nf);
- if (dterr == 0)
- dterr = DecodeDateTime(field, ftype, nf, &dtype, tm, &fsec, &tz);
- if (dterr != 0)
- DateTimeParseError(dterr, str, "timestamp");
- =====================================================================
- Found a 21 line (111 tokens) duplication in the following files:
- Starting at line 3399 of /home/shackle/pggit/postgresql/src/backend/utils/adt/timestamp.c
- Starting at line 3483 of /home/shackle/pggit/postgresql/src/backend/utils/adt/timestamp.c
- interval_accum(PG_FUNCTION_ARGS)
- {
- ArrayType *transarray = PG_GETARG_ARRAYTYPE_P(0);
- Interval *newval = PG_GETARG_INTERVAL_P(1);
- Datum *transdatums;
- int ndatums;
- Interval sumX,
- N;
- Interval *newsum;
- ArrayType *result;
- deconstruct_array(transarray,
- INTERVALOID, sizeof(Interval), false, 'd',
- &transdatums, NULL, &ndatums);
- if (ndatums != 2)
- elog(ERROR, "expected 2-element interval array");
- sumX = *(DatumGetIntervalP(transdatums[0]));
- N = *(DatumGetIntervalP(transdatums[1]));
- newsum = DatumGetIntervalP(DirectFunctionCall2(interval_pl,
- =====================================================================
- Found a 31 line (111 tokens) duplication in the following files:
- Starting at line 603 of /home/shackle/pggit/postgresql/src/backend/utils/adt/int.c
- Starting at line 685 of /home/shackle/pggit/postgresql/src/backend/utils/adt/int.c
- int32 base = PG_GETARG_INT32(1);
- int32 offset = PG_GETARG_INT32(2);
- bool sub = PG_GETARG_BOOL(3);
- bool less = PG_GETARG_BOOL(4);
- int32 sum;
- if (offset < 0)
- ereport(ERROR,
- (errcode(ERRCODE_INVALID_PRECEDING_OR_FOLLOWING_SIZE),
- errmsg("invalid preceding or following size in window function")));
- if (sub)
- offset = -offset; /* cannot overflow */
- if (unlikely(pg_add_s32_overflow(base, offset, &sum)))
- {
- /*
- * If sub is false, the true sum is surely more than val, so correct
- * answer is the same as "less". If sub is true, the true sum is
- * surely less than val, so the answer is "!less".
- */
- PG_RETURN_BOOL(sub ? !less : less);
- }
- if (less)
- PG_RETURN_BOOL(val <= sum);
- else
- PG_RETURN_BOOL(val >= sum);
- }
- Datum
- =====================================================================
- Found a 34 line (111 tokens) duplication in the following files:
- Starting at line 145 of /home/shackle/pggit/postgresql/src/backend/access/common/tupconvert.c
- Starting at line 348 of /home/shackle/pggit/postgresql/src/backend/access/common/tupconvert.c
- for (i = 0; i < n; i++)
- {
- Form_pg_attribute inatt;
- Form_pg_attribute outatt;
- if (attrMap[i] == (i + 1))
- continue;
- /*
- * If it's a dropped column and the corresponding input column is
- * also dropped, we needn't convert. However, attlen and attalign
- * must agree.
- */
- inatt = TupleDescAttr(indesc, i);
- outatt = TupleDescAttr(outdesc, i);
- if (attrMap[i] == 0 &&
- inatt->attisdropped &&
- inatt->attlen == outatt->attlen &&
- inatt->attalign == outatt->attalign)
- continue;
- same = false;
- break;
- }
- }
- else
- same = false;
- if (same)
- {
- /* Runtime conversion is not needed */
- pfree(attrMap);
- return NULL;
- }
- =====================================================================
- Found a 30 line (110 tokens) duplication in the following files:
- Starting at line 59 of /home/shackle/pggit/postgresql/src/bin/scripts/dropuser.c
- Starting at line 60 of /home/shackle/pggit/postgresql/src/bin/scripts/dropdb.c
- handle_help_version_opts(argc, argv, "dropuser", help);
- while ((c = getopt_long(argc, argv, "h:p:U:wWei", long_options, &optindex)) != -1)
- {
- switch (c)
- {
- case 'h':
- host = pg_strdup(optarg);
- break;
- case 'p':
- port = pg_strdup(optarg);
- break;
- case 'U':
- username = pg_strdup(optarg);
- break;
- case 'w':
- prompt_password = TRI_NO;
- break;
- case 'W':
- prompt_password = TRI_YES;
- break;
- case 'e':
- echo = true;
- break;
- case 'i':
- interactive = true;
- break;
- case 0:
- /* this covers the long options */
- break;
- =====================================================================
- Found a 32 line (110 tokens) duplication in the following files:
- Starting at line 5053 of /home/shackle/pggit/postgresql/src/pl/plpgsql/src/pl_exec.c
- Starting at line 6513 of /home/shackle/pggit/postgresql/src/pl/plpgsql/src/pl_exec.c
- ExpandedRecordHeader *erh;
- rec = (PLpgSQL_rec *) (estate->datums[recfield->recparentno]);
- erh = rec->erh;
- /*
- * If record variable is NULL, instantiate it if it has a
- * named composite type, else complain. (This won't change
- * the logical state of the record, but if we successfully
- * assign below, the unassigned fields will all become NULLs.)
- */
- if (erh == NULL)
- {
- instantiate_empty_record_variable(estate, rec);
- erh = rec->erh;
- }
- /*
- * Look up the field's properties if we have not already, or
- * if the tuple descriptor ID changed since last time.
- */
- if (unlikely(recfield->rectupledescid != erh->er_tupdesc_id))
- {
- if (!expanded_record_lookup_field(erh,
- recfield->fieldname,
- &recfield->finfo))
- ereport(ERROR,
- (errcode(ERRCODE_UNDEFINED_COLUMN),
- errmsg("record \"%s\" has no field \"%s\"",
- rec->refname, recfield->fieldname)));
- recfield->rectupledescid = erh->er_tupdesc_id;
- }
- =====================================================================
- Found a 17 line (110 tokens) duplication in the following files:
- Starting at line 377 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c
- Starting at line 438 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c
- inp_sqlda = (sqlda_t *)malloc(sizeof(sqlda_t));
- memset(inp_sqlda, 0, sizeof(sqlda_t));
- inp_sqlda->sqld = 1;
- inp_sqlda->sqlvar = malloc(sizeof(sqlvar_t));
- memset(inp_sqlda->sqlvar, 0, sizeof(sqlvar_t));
- inp_sqlda->sqlvar[0].sqltype = SQLINT;
- inp_sqlda->sqlvar[0].sqldata = (char *)&id;
- printf("EXECUTE RECORD 4\n");
- id = 4;
- outp_sqlda = NULL;
- strcpy(msg, "prepare");
- { ECPGprepare(__LINE__, NULL, 0, "st_id3", stmt2);
- =====================================================================
- Found a 28 line (110 tokens) duplication in the following files:
- Starting at line 1499 of /home/shackle/pggit/postgresql/src/backend/regex/regc_nfa.c
- Starting at line 1666 of /home/shackle/pggit/postgresql/src/backend/regex/regc_nfa.c
- if (pull(nfa, a, &intermediates))
- progress = 1;
- }
- /* clear tmp fields of intermediate states created here */
- while (intermediates != NULL)
- {
- struct state *ns = intermediates->tmp;
- intermediates->tmp = NULL;
- intermediates = ns;
- }
- /* if s is now useless, get rid of it */
- if ((s->nins == 0 || s->nouts == 0) && !s->flag)
- dropstate(nfa, s);
- }
- if (progress && f != NULL)
- dumpnfa(nfa, f);
- } while (progress && !NISERR());
- if (NISERR())
- return;
- /*
- * Any ^ constraints we were able to pull to the start state can now be
- * replaced by PLAIN arcs referencing the BOS or BOL colors. There should
- * be no other ^ or BEHIND arcs left in the NFA, though we do not check
- * that here (compact() will fail if so).
- */
- for (a = nfa->pre->outs; a != NULL; a = nexta)
- =====================================================================
- Found a 25 line (110 tokens) duplication in the following files:
- Starting at line 223 of /home/shackle/pggit/postgresql/src/backend/executor/nodeGatherMerge.c
- Starting at line 179 of /home/shackle/pggit/postgresql/src/backend/executor/nodeGather.c
- gm->initParam);
- /* Try to launch workers. */
- pcxt = node->pei->pcxt;
- LaunchParallelWorkers(pcxt);
- /* We save # workers launched for the benefit of EXPLAIN */
- node->nworkers_launched = pcxt->nworkers_launched;
- /* Set up tuple queue readers to read the results. */
- if (pcxt->nworkers_launched > 0)
- {
- ExecParallelCreateReaders(node->pei);
- /* Make a working array showing the active readers */
- node->nreaders = pcxt->nworkers_launched;
- node->reader = (TupleQueueReader **)
- palloc(node->nreaders * sizeof(TupleQueueReader *));
- memcpy(node->reader, node->pei->reader,
- node->nreaders * sizeof(TupleQueueReader *));
- }
- else
- {
- /* No workers? Then never mind. */
- node->nreaders = 0;
- node->reader = NULL;
- }
- =====================================================================
- Found a 28 line (110 tokens) duplication in the following files:
- Starting at line 1414 of /home/shackle/pggit/postgresql/src/backend/executor/nodeIndexscan.c
- Starting at line 1533 of /home/shackle/pggit/postgresql/src/backend/executor/nodeIndexscan.c
- Assert(rightop != NULL);
- if (IsA(rightop, Const))
- {
- /* OK, simple constant comparison value */
- scanvalue = ((Const *) rightop)->constvalue;
- if (((Const *) rightop)->constisnull)
- flags |= SK_ISNULL;
- }
- else
- {
- /* Need to treat this one as a runtime key */
- if (n_runtime_keys >= max_runtime_keys)
- {
- if (max_runtime_keys == 0)
- {
- max_runtime_keys = 8;
- runtime_keys = (IndexRuntimeKeyInfo *)
- palloc(max_runtime_keys * sizeof(IndexRuntimeKeyInfo));
- }
- else
- {
- max_runtime_keys *= 2;
- runtime_keys = (IndexRuntimeKeyInfo *)
- repalloc(runtime_keys, max_runtime_keys * sizeof(IndexRuntimeKeyInfo));
- }
- }
- runtime_keys[n_runtime_keys].scan_key = this_sub_key;
- =====================================================================
- Found a 5 line (110 tokens) duplication in the following files:
- Starting at line 98 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
- Starting at line 103 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- =====================================================================
- Found a 25 line (110 tokens) duplication in the following files:
- Starting at line 472 of /home/shackle/pggit/postgresql/src/backend/utils/adt/genfile.c
- Starting at line 550 of /home/shackle/pggit/postgresql/src/backend/utils/adt/genfile.c
- fctx->include_dot_dirs = include_dot_dirs;
- fctx->dirdesc = AllocateDir(fctx->location);
- if (!fctx->dirdesc)
- {
- if (missing_ok && errno == ENOENT)
- {
- MemoryContextSwitchTo(oldcontext);
- SRF_RETURN_DONE(funcctx);
- }
- else
- ereport(ERROR,
- (errcode_for_file_access(),
- errmsg("could not open directory \"%s\": %m",
- fctx->location)));
- }
- funcctx->user_fctx = fctx;
- MemoryContextSwitchTo(oldcontext);
- }
- funcctx = SRF_PERCALL_SETUP();
- fctx = (directory_fctx *) funcctx->user_fctx;
- while ((de = ReadDir(fctx->dirdesc, fctx->location)) != NULL)
- {
- =====================================================================
- Found a 35 line (110 tokens) duplication in the following files:
- Starting at line 72 of /home/shackle/pggit/postgresql/src/backend/replication/walreceiverfuncs.c
- Starting at line 117 of /home/shackle/pggit/postgresql/src/backend/replication/walreceiverfuncs.c
- WalRcvRunning(void)
- {
- WalRcvData *walrcv = WalRcv;
- WalRcvState state;
- pg_time_t startTime;
- SpinLockAcquire(&walrcv->mutex);
- state = walrcv->walRcvState;
- startTime = walrcv->startTime;
- SpinLockRelease(&walrcv->mutex);
- /*
- * If it has taken too long for walreceiver to start up, give up. Setting
- * the state to STOPPED ensures that if walreceiver later does start up
- * after all, it will see that it's not supposed to be running and die
- * without doing anything.
- */
- if (state == WALRCV_STARTING)
- {
- pg_time_t now = (pg_time_t) time(NULL);
- if ((now - startTime) > WALRCV_STARTUP_TIMEOUT)
- {
- SpinLockAcquire(&walrcv->mutex);
- if (walrcv->walRcvState == WALRCV_STARTING)
- state = walrcv->walRcvState = WALRCV_STOPPED;
- SpinLockRelease(&walrcv->mutex);
- }
- }
- if (state != WALRCV_STOPPED)
- =====================================================================
- Found a 13 line (109 tokens) duplication in the following files:
- Starting at line 6214 of /home/shackle/pggit/postgresql/src/pl/plperl/ppport.h
- Starting at line 6234 of /home/shackle/pggit/postgresql/src/pl/plperl/ppport.h
- int digit = *s - '0';
- if (digit >= 0 && digit <= 9) {
- value = value * 10 + digit;
- if (++s < send) {
- digit = *s - '0';
- if (digit >= 0 && digit <= 9) {
- value = value * 10 + digit;
- if (++s < send) {
- digit = *s - '0';
- if (digit >= 0 && digit <= 9) {
- value = value * 10 + digit;
- if (++s < send) {
- digit = *s - '0';
- =====================================================================
- Found a 3 line (109 tokens) duplication in the following files:
- Starting at line 3566 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
- Starting at line 120 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 46 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1,
- -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- =====================================================================
- Found a 3 line (109 tokens) duplication in the following files:
- Starting at line 3568 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
- Starting at line 118 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 44 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- =====================================================================
- Found a 19 line (109 tokens) duplication in the following files:
- Starting at line 1073 of /home/shackle/pggit/postgresql/src/backend/optimizer/prep/prepjointree.c
- Starting at line 1674 of /home/shackle/pggit/postgresql/src/backend/optimizer/prep/prepjointree.c
- parse->targetList = (List *)
- pullup_replace_vars((Node *) parse->targetList, &rvcontext);
- parse->returningList = (List *)
- pullup_replace_vars((Node *) parse->returningList, &rvcontext);
- if (parse->onConflict)
- {
- parse->onConflict->onConflictSet = (List *)
- pullup_replace_vars((Node *) parse->onConflict->onConflictSet,
- &rvcontext);
- parse->onConflict->onConflictWhere =
- pullup_replace_vars(parse->onConflict->onConflictWhere,
- &rvcontext);
- /*
- * We assume ON CONFLICT's arbiterElems, arbiterWhere, exclRelTlist
- * can't contain any references to a subquery
- */
- }
- replace_vars_in_jointree((Node *) parse->jointree, &rvcontext,
- =====================================================================
- Found a 41 line (109 tokens) duplication in the following files:
- Starting at line 773 of /home/shackle/pggit/postgresql/src/backend/utils/mmgr/mcxt.c
- Starting at line 928 of /home/shackle/pggit/postgresql/src/backend/utils/mmgr/mcxt.c
- void *ret;
- AssertArg(MemoryContextIsValid(context));
- AssertNotInCriticalSection(context);
- if (!AllocSizeIsValid(size))
- elog(ERROR, "invalid memory alloc request size %zu", size);
- context->isReset = false;
- ret = context->methods->alloc(context, size);
- if (unlikely(ret == NULL))
- {
- MemoryContextStats(TopMemoryContext);
- /*
- * Here, and elsewhere in this module, we show the target context's
- * "name" but not its "ident" (if any) in user-visible error messages.
- * The "ident" string might contain security-sensitive data, such as
- * values in SQL commands.
- */
- ereport(ERROR,
- (errcode(ERRCODE_OUT_OF_MEMORY),
- errmsg("out of memory"),
- errdetail("Failed on request of size %zu in memory context \"%s\".",
- size, context->name)));
- }
- VALGRIND_MEMPOOL_ALLOC(context, ret, size);
- return ret;
- }
- /*
- * MemoryContextAllocZero
- * Like MemoryContextAlloc, but clears allocated memory
- *
- * We could just call MemoryContextAlloc then clear the memory, but this
- * is a very common combination, so we provide the combined operation.
- */
- void *
- =====================================================================
- Found a 29 line (109 tokens) duplication in the following files:
- Starting at line 445 of /home/shackle/pggit/postgresql/src/backend/access/nbtree/nbtpage.c
- Starting at line 549 of /home/shackle/pggit/postgresql/src/backend/access/nbtree/nbtpage.c
- _bt_cachemetadata(rel, metad);
- /*
- * We are done with the metapage; arrange to release it via first
- * _bt_relandgetbuf call
- */
- rootbuf = metabuf;
- for (;;)
- {
- rootbuf = _bt_relandgetbuf(rel, rootbuf, rootblkno, BT_READ);
- rootpage = BufferGetPage(rootbuf);
- rootopaque = (BTPageOpaque) PageGetSpecialPointer(rootpage);
- if (!P_IGNORE(rootopaque))
- break;
- /* it's dead, Jim. step right one page */
- if (P_RIGHTMOST(rootopaque))
- elog(ERROR, "no live root page found in index \"%s\"",
- RelationGetRelationName(rel));
- rootblkno = rootopaque->btpo_next;
- }
- /* Note: can't check btpo.level on deleted pages */
- if (rootopaque->btpo.level != rootlevel)
- elog(ERROR, "root page %u of index \"%s\" has level %u, expected %u",
- rootblkno, RelationGetRelationName(rel),
- rootopaque->btpo.level, rootlevel);
- =====================================================================
- Found a 39 line (108 tokens) duplication in the following files:
- Starting at line 623 of /home/shackle/pggit/postgresql/contrib/pg_trgm/trgm_gist.c
- Starting at line 492 of /home/shackle/pggit/postgresql/src/backend/utils/adt/tsgistidx.c
- if (CMPTRGM(ptra + i, ptrb + i))
- {
- *result = false;
- break;
- }
- }
- }
- PG_RETURN_POINTER(result);
- }
- static int32
- sizebitvec(BITVECP sign)
- {
- int32 size = 0,
- i;
- LOOPBYTE
- size += number_of_ones[(unsigned char) sign[i]];
- return size;
- }
- static int
- hemdistsign(BITVECP a, BITVECP b)
- {
- int i,
- diff,
- dist = 0;
- LOOPBYTE
- {
- diff = (unsigned char) (a[i] ^ b[i]);
- dist += number_of_ones[diff];
- }
- return dist;
- }
- static int
- hemdist(TRGM *a, TRGM *b)
- =====================================================================
- Found a 29 line (108 tokens) duplication in the following files:
- Starting at line 621 of /home/shackle/pggit/postgresql/contrib/pgcrypto/imath.c
- Starting at line 713 of /home/shackle/pggit/postgresql/contrib/pgcrypto/imath.c
- if (MP_SIGN(a) == MP_SIGN(b))
- {
- /* Same sign -- add magnitudes, preserve sign of addends */
- mp_digit carry;
- if (!s_pad(c, max))
- return MP_MEMORY;
- carry = s_uadd(MP_DIGITS(a), MP_DIGITS(b), MP_DIGITS(c), ua, ub);
- uc = max;
- if (carry)
- {
- if (!s_pad(c, max + 1))
- return MP_MEMORY;
- c->digits[max] = carry;
- ++uc;
- }
- MP_USED(c) = uc;
- MP_SIGN(c) = MP_SIGN(a);
- }
- else
- {
- /* Different signs -- subtract magnitudes, preserve sign of greater */
- mp_int x,
- y;
- =====================================================================
- Found a 34 line (108 tokens) duplication in the following files:
- Starting at line 917 of /home/shackle/pggit/postgresql/src/bin/pg_dump/dumputils.c
- Starting at line 3425 of /home/shackle/pggit/postgresql/src/backend/utils/adt/varlena.c
- while (isspace((unsigned char) *nextp))
- nextp++; /* skip leading whitespace */
- if (*nextp == '\0')
- return true; /* allow empty string */
- /* At the top of the loop, we are at start of a new identifier. */
- do
- {
- char *curname;
- char *endp;
- if (*nextp == '"')
- {
- /* Quoted name --- collapse quote-quote pairs */
- curname = nextp + 1;
- for (;;)
- {
- endp = strchr(nextp + 1, '"');
- if (endp == NULL)
- return false; /* mismatched quotes */
- if (endp[1] != '"')
- break; /* found end of quoted name */
- /* Collapse adjacent quotes into one quote, and look again */
- memmove(endp, endp + 1, strlen(endp));
- nextp = endp;
- }
- /* endp now points at the terminating quote */
- nextp = endp + 1;
- }
- else
- {
- /* Unquoted name --- extends to separator or whitespace */
- curname = nextp;
- =====================================================================
- Found a 3 line (108 tokens) duplication in the following files:
- Starting at line 31 of /home/shackle/pggit/postgresql/src/common/base64.c
- Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
- Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 207 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
- =====================================================================
- Found a 3 line (108 tokens) duplication in the following files:
- Starting at line 31 of /home/shackle/pggit/postgresql/src/common/base64.c
- Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
- Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 207 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
- =====================================================================
- Found a 5 line (108 tokens) duplication in the following files:
- Starting at line 98 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
- Starting at line 103 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- =====================================================================
- Found a 27 line (108 tokens) duplication in the following files:
- Starting at line 3428 of /home/shackle/pggit/postgresql/src/backend/utils/adt/jsonfuncs.c
- Starting at line 3881 of /home/shackle/pggit/postgresql/src/backend/utils/adt/jsonfuncs.c
- hashentry = hash_search(_state->hash, fname, HASH_ENTER, &found);
- /*
- * found being true indicates a duplicate. We don't do anything about
- * that, a later field with the same name overrides the earlier field.
- */
- hashentry->type = _state->saved_token_type;
- Assert(isnull == (hashentry->type == JSON_TOKEN_NULL));
- if (_state->save_json_start != NULL)
- {
- int len = _state->lex->prev_token_terminator - _state->save_json_start;
- char *val = palloc((len + 1) * sizeof(char));
- memcpy(val, _state->save_json_start, len);
- val[len] = '\0';
- hashentry->val = val;
- }
- else
- {
- /* must have had a scalar instead */
- hashentry->val = _state->saved_scalar;
- }
- }
- static void
- =====================================================================
- Found a 38 line (108 tokens) duplication in the following files:
- Starting at line 552 of /home/shackle/pggit/postgresql/src/backend/access/heap/heapam.c
- Starting at line 853 of /home/shackle/pggit/postgresql/src/backend/access/heap/heapam.c
- linesleft = lines - lineoff + 1;
- }
- else if (backward)
- {
- /* backward parallel scan not supported */
- Assert(scan->rs_parallel == NULL);
- if (!scan->rs_inited)
- {
- /*
- * return null immediately if relation is empty
- */
- if (scan->rs_nblocks == 0 || scan->rs_numblocks == 0)
- {
- Assert(!BufferIsValid(scan->rs_cbuf));
- tuple->t_data = NULL;
- return;
- }
- /*
- * Disable reporting to syncscan logic in a backwards scan; it's
- * not very likely anyone else is doing the same thing at the same
- * time, and much more likely that we'll just bollix things for
- * forward scanners.
- */
- scan->rs_syncscan = false;
- /* start from last page of the scan */
- if (scan->rs_startblock > 0)
- page = scan->rs_startblock - 1;
- else
- page = scan->rs_nblocks - 1;
- heapgetpage(scan, page);
- }
- else
- {
- /* continue from previously returned page/tuple */
- page = scan->rs_cblock; /* current page */
- }
- =====================================================================
- Found a 35 line (108 tokens) duplication in the following files:
- Starting at line 231 of /home/shackle/pggit/postgresql/src/backend/access/transam/xloginsert.c
- Starting at line 286 of /home/shackle/pggit/postgresql/src/backend/access/transam/xloginsert.c
- regbuf->page = BufferGetPage(buffer);
- regbuf->flags = flags;
- regbuf->rdata_tail = (XLogRecData *) ®buf->rdata_head;
- regbuf->rdata_len = 0;
- /*
- * Check that this page hasn't already been registered with some other
- * block_id.
- */
- #ifdef USE_ASSERT_CHECKING
- {
- int i;
- for (i = 0; i < max_registered_block_id; i++)
- {
- registered_buffer *regbuf_old = ®istered_buffers[i];
- if (i == block_id || !regbuf_old->in_use)
- continue;
- Assert(!RelFileNodeEquals(regbuf_old->rnode, regbuf->rnode) ||
- regbuf_old->forkno != regbuf->forkno ||
- regbuf_old->block != regbuf->block);
- }
- }
- #endif
- regbuf->in_use = true;
- }
- /*
- * Like XLogRegisterBuffer, but for registering a block that's not in the
- * shared buffer pool (i.e. when you don't have a Buffer for it).
- */
- void
- =====================================================================
- Found a 26 line (107 tokens) duplication in the following files:
- Starting at line 178 of /home/shackle/pggit/postgresql/contrib/pageinspect/btreefuncs.c
- Starting at line 332 of /home/shackle/pggit/postgresql/contrib/pageinspect/btreefuncs.c
- (errmsg("must be superuser to use pageinspect functions"))));
- relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
- rel = relation_openrv(relrv, AccessShareLock);
- if (!IS_INDEX(rel) || !IS_BTREE(rel))
- elog(ERROR, "relation \"%s\" is not a btree index",
- RelationGetRelationName(rel));
- /*
- * Reject attempts to read non-local temporary relations; we would be
- * likely to get wrong data since we have no visibility into the owning
- * session's local buffers.
- */
- if (RELATION_IS_OTHER_TEMP(rel))
- ereport(ERROR,
- (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("cannot access temporary tables of other sessions")));
- if (blkno == 0)
- elog(ERROR, "block 0 is a meta page");
- CHECK_RELATION_BLOCK_RANGE(rel, blkno);
- buffer = ReadBuffer(rel, blkno);
- LockBuffer(buffer, BUFFER_LOCK_SHARE);
- =====================================================================
- Found a 27 line (107 tokens) duplication in the following files:
- Starting at line 614 of /home/shackle/pggit/postgresql/src/bin/initdb/initdb.c
- Starting at line 177 of /home/shackle/pggit/postgresql/src/bin/pg_basebackup/pg_basebackup.c
- if (!rmtree(pg_data, false))
- fprintf(stderr, _("%s: failed to remove contents of data directory\n"),
- progname);
- }
- if (made_new_xlogdir)
- {
- fprintf(stderr, _("%s: removing WAL directory \"%s\"\n"),
- progname, xlog_dir);
- if (!rmtree(xlog_dir, true))
- fprintf(stderr, _("%s: failed to remove WAL directory\n"),
- progname);
- }
- else if (found_existing_xlogdir)
- {
- fprintf(stderr,
- _("%s: removing contents of WAL directory \"%s\"\n"),
- progname, xlog_dir);
- if (!rmtree(xlog_dir, false))
- fprintf(stderr, _("%s: failed to remove contents of WAL directory\n"),
- progname);
- }
- /* otherwise died during startup, do nothing! */
- }
- else
- {
- if (made_new_pgdata || found_existing_pgdata)
- =====================================================================
- Found a 29 line (107 tokens) duplication in the following files:
- Starting at line 199 of /home/shackle/pggit/postgresql/src/include/catalog/pg_constraint.h
- Starting at line 56 of /home/shackle/pggit/postgresql/src/backend/catalog/pg_constraint.c
- extern Oid CreateConstraintEntry(const char *constraintName,
- Oid constraintNamespace,
- char constraintType,
- bool isDeferrable,
- bool isDeferred,
- bool isValidated,
- Oid parentConstrId,
- Oid relId,
- const int16 *constraintKey,
- int constraintNKeys,
- int constraintNTotalKeys,
- Oid domainId,
- Oid indexRelId,
- Oid foreignRelId,
- const int16 *foreignKey,
- const Oid *pfEqOp,
- const Oid *ppEqOp,
- const Oid *ffEqOp,
- int foreignNKeys,
- char foreignUpdateType,
- char foreignDeleteType,
- char foreignMatchType,
- const Oid *exclOp,
- Node *conExpr,
- const char *conBin,
- bool conIsLocal,
- int conInhCount,
- bool conNoInherit,
- bool is_internal);
- =====================================================================
- Found a 26 line (107 tokens) duplication in the following files:
- Starting at line 570 of /home/shackle/pggit/postgresql/src/pl/plpgsql/src/pl_exec.c
- Starting at line 940 of /home/shackle/pggit/postgresql/src/pl/plpgsql/src/pl_exec.c
- estate.err_text = gettext_noop("during function entry");
- /*
- * Set the magic variable FOUND to false
- */
- exec_set_found(&estate, false);
- /*
- * Let the instrumentation plugin peek at this function
- */
- if (*plpgsql_plugin_ptr && (*plpgsql_plugin_ptr)->func_beg)
- ((*plpgsql_plugin_ptr)->func_beg) (&estate, func);
- /*
- * Now call the toplevel block of statements
- */
- estate.err_text = NULL;
- estate.err_stmt = (PLpgSQL_stmt *) (func->action);
- rc = exec_stmt_block(&estate, func->action);
- if (rc != PLPGSQL_RC_RETURN)
- {
- estate.err_stmt = NULL;
- estate.err_text = NULL;
- ereport(ERROR,
- (errcode(ERRCODE_S_R_E_FUNCTION_EXECUTED_NO_RETURN_STATEMENT),
- errmsg("control reached end of function without RETURN")));
- =====================================================================
- Found a 41 line (107 tokens) duplication in the following files:
- Starting at line 306 of /home/shackle/pggit/postgresql/src/pl/plpython/plpy_typeio.c
- Starting at line 429 of /home/shackle/pggit/postgresql/src/pl/plpython/plpy_typeio.c
- Oid typinput;
- /* Since this is recursive, it could theoretically be driven to overflow */
- check_stack_depth();
- arg->typoid = typeOid;
- arg->typmod = typmod;
- arg->mcxt = arg_mcxt;
- /*
- * Fetch typcache entry for the target type, asking for whatever info
- * we'll need later. RECORD is a special case: just treat it as composite
- * without bothering with the typcache entry.
- */
- if (typeOid != RECORDOID)
- {
- typentry = lookup_type_cache(typeOid, TYPECACHE_DOMAIN_BASE_INFO);
- typtype = typentry->typtype;
- arg->typbyval = typentry->typbyval;
- arg->typlen = typentry->typlen;
- arg->typalign = typentry->typalign;
- }
- else
- {
- typentry = NULL;
- typtype = TYPTYPE_COMPOSITE;
- /* hard-wired knowledge about type RECORD: */
- arg->typbyval = false;
- arg->typlen = -1;
- arg->typalign = 'd';
- }
- /*
- * Choose conversion method. Note that transform functions are checked
- * for composite and scalar types, but not for arrays or domains. This is
- * somewhat historical, but we'd have a problem allowing them on domains,
- * since we drill down through all levels of a domain nest without looking
- * at the intermediate levels at all.
- */
- if (typtype == TYPTYPE_DOMAIN)
- {
- =====================================================================
- Found a 48 line (107 tokens) duplication in the following files:
- Starting at line 28 of /home/shackle/pggit/postgresql/src/test/examples/testlibpq.c
- Starting at line 57 of /home/shackle/pggit/postgresql/src/test/examples/testlibpq2.c
- j;
- /*
- * If the user supplies a parameter on the command line, use it as the
- * conninfo string; otherwise default to setting dbname=postgres and using
- * environment variables or defaults for all other connection parameters.
- */
- if (argc > 1)
- conninfo = argv[1];
- else
- conninfo = "dbname = postgres";
- /* Make a connection to the database */
- conn = PQconnectdb(conninfo);
- /* Check to see that the backend connection was successfully made */
- if (PQstatus(conn) != CONNECTION_OK)
- {
- fprintf(stderr, "Connection to database failed: %s",
- PQerrorMessage(conn));
- exit_nicely(conn);
- }
- /* Set always-secure search path, so malicious users can't take control. */
- res = PQexec(conn,
- "SELECT pg_catalog.set_config('search_path', '', false)");
- if (PQresultStatus(res) != PGRES_TUPLES_OK)
- {
- fprintf(stderr, "SET failed: %s", PQerrorMessage(conn));
- PQclear(res);
- exit_nicely(conn);
- }
- /*
- * Should PQclear PGresult whenever it is no longer needed to avoid memory
- * leaks
- */
- PQclear(res);
- /*
- * Our test case here involves using a cursor, for which we must be inside
- * a transaction block. We could do the whole thing with a single
- * PQexec() of "select * from pg_database", but that's too trivial to make
- * a good example.
- */
- /* Start a transaction block */
- res = PQexec(conn, "BEGIN");
- =====================================================================
- Found a 36 line (107 tokens) duplication in the following files:
- Starting at line 752 of /home/shackle/pggit/postgresql/src/backend/regex/regc_nfa.c
- Starting at line 841 of /home/shackle/pggit/postgresql/src/backend/regex/regc_nfa.c
- }
- else
- {
- /*
- * With many arcs, use a sort-merge approach. Note changearctarget()
- * will put the arc onto the front of newState's chain, so it does not
- * break our walk through the sorted part of the chain.
- */
- struct arc *oa;
- struct arc *na;
- /*
- * Because we bypass newarc() in this code path, we'd better include a
- * cancel check.
- */
- if (CANCEL_REQUESTED(nfa->v->re))
- {
- NERR(REG_CANCEL);
- return;
- }
- sortins(nfa, oldState);
- sortins(nfa, newState);
- if (NISERR())
- return; /* might have failed to sort */
- oa = oldState->ins;
- na = newState->ins;
- while (oa != NULL && na != NULL)
- {
- struct arc *a = oa;
- switch (sortins_cmp(&oa, &na))
- {
- case -1:
- /* newState does not have anything matching oa */
- oa = oa->inchain;
- =====================================================================
- Found a 24 line (107 tokens) duplication in the following files:
- Starting at line 367 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c
- Starting at line 471 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c
- int c1;
- int l;
- while (len > 0)
- {
- c1 = *euc;
- if (!IS_HIGHBIT_SET(c1))
- {
- /* ASCII */
- if (c1 == 0)
- report_invalid_encoding(PG_EUC_JP,
- (const char *) euc, len);
- *p++ = c1;
- euc++;
- len--;
- continue;
- }
- l = pg_encoding_verifymb(PG_EUC_JP, (const char *) euc, len);
- if (l < 0)
- report_invalid_encoding(PG_EUC_JP,
- (const char *) euc, len);
- if (c1 == SS2)
- { /* 1 byte kana? */
- *p++ = LC_JISX0201K;
- =====================================================================
- Found a 50 line (107 tokens) duplication in the following files:
- Starting at line 6625 of /home/shackle/pggit/postgresql/src/backend/utils/adt/numeric.c
- Starting at line 6742 of /home/shackle/pggit/postgresql/src/backend/utils/adt/numeric.c
- if (var2->sign == NUMERIC_POS)
- {
- /*
- * Both are positive result = +(ABS(var1) + ABS(var2))
- */
- add_abs(var1, var2, result);
- result->sign = NUMERIC_POS;
- }
- else
- {
- /*
- * var1 is positive, var2 is negative Must compare absolute values
- */
- switch (cmp_abs(var1, var2))
- {
- case 0:
- /* ----------
- * ABS(var1) == ABS(var2)
- * result = ZERO
- * ----------
- */
- zero_var(result);
- result->dscale = Max(var1->dscale, var2->dscale);
- break;
- case 1:
- /* ----------
- * ABS(var1) > ABS(var2)
- * result = +(ABS(var1) - ABS(var2))
- * ----------
- */
- sub_abs(var1, var2, result);
- result->sign = NUMERIC_POS;
- break;
- case -1:
- /* ----------
- * ABS(var1) < ABS(var2)
- * result = -(ABS(var2) - ABS(var1))
- * ----------
- */
- sub_abs(var2, var1, result);
- result->sign = NUMERIC_NEG;
- break;
- }
- }
- }
- else
- {
- if (var2->sign == NUMERIC_POS)
- =====================================================================
- Found a 38 line (107 tokens) duplication in the following files:
- Starting at line 2163 of /home/shackle/pggit/postgresql/src/backend/utils/adt/float.c
- Starting at line 2227 of /home/shackle/pggit/postgresql/src/backend/utils/adt/float.c
- Starting at line 2282 of /home/shackle/pggit/postgresql/src/backend/utils/adt/float.c
- volatile float8 cot_arg1;
- int sign = 1;
- /*
- * Per the POSIX spec, return NaN if the input is NaN and throw an error
- * if the input is infinite.
- */
- if (isnan(arg1))
- PG_RETURN_FLOAT8(get_float8_nan());
- if (isinf(arg1))
- ereport(ERROR,
- (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
- errmsg("input is out of range")));
- INIT_DEGREE_CONSTANTS();
- /* Reduce the range of the input to [0,90] degrees */
- arg1 = fmod(arg1, 360.0);
- if (arg1 < 0.0)
- {
- /* cotd(-x) = -cotd(x) */
- arg1 = -arg1;
- sign = -sign;
- }
- if (arg1 > 180.0)
- {
- /* cotd(360-x) = -cotd(x) */
- arg1 = 360.0 - arg1;
- sign = -sign;
- }
- if (arg1 > 90.0)
- {
- /* cotd(180-x) = -cotd(x) */
- arg1 = 180.0 - arg1;
- =====================================================================
- Found a 30 line (107 tokens) duplication in the following files:
- Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/enum.c
- Starting at line 183 of /home/shackle/pggit/postgresql/src/backend/utils/adt/enum.c
- HeapTuple tup;
- /* must check length to prevent Assert failure within SearchSysCache */
- if (strlen(name) >= NAMEDATALEN)
- ereport(ERROR,
- (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
- errmsg("invalid input value for enum %s: \"%s\"",
- format_type_be(enumtypoid),
- name)));
- tup = SearchSysCache2(ENUMTYPOIDNAME,
- ObjectIdGetDatum(enumtypoid),
- CStringGetDatum(name));
- if (!HeapTupleIsValid(tup))
- ereport(ERROR,
- (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
- errmsg("invalid input value for enum %s: \"%s\"",
- format_type_be(enumtypoid),
- name)));
- /* check it's safe to use in SQL */
- check_safe_enum_use(tup);
- /*
- * This comes from pg_enum.oid and stores system oids in user tables. This
- * oid must be preserved by binary upgrades.
- */
- enumoid = ((Form_pg_enum) GETSTRUCT(tup))->oid;
- ReleaseSysCache(tup);
- =====================================================================
- Found a 26 line (107 tokens) duplication in the following files:
- Starting at line 126 of /home/shackle/pggit/postgresql/src/backend/utils/adt/numutils.c
- Starting at line 202 of /home/shackle/pggit/postgresql/src/backend/utils/adt/numutils.c
- int16 tmp = 0;
- bool neg = false;
- /* skip leading spaces */
- while (likely(*ptr) && isspace((unsigned char) *ptr))
- ptr++;
- /* handle sign */
- if (*ptr == '-')
- {
- ptr++;
- neg = true;
- }
- else if (*ptr == '+')
- ptr++;
- /* require at least one digit */
- if (unlikely(!isdigit((unsigned char) *ptr)))
- goto invalid_syntax;
- /* process digits */
- while (*ptr && isdigit((unsigned char) *ptr))
- {
- int8 digit = (*ptr++ - '0');
- if (unlikely(pg_mul_s16_overflow(tmp, 10, &tmp)) ||
- =====================================================================
- Found a 26 line (107 tokens) duplication in the following files:
- Starting at line 390 of /home/shackle/pggit/postgresql/src/backend/utils/adt/ri_triggers.c
- Starting at line 526 of /home/shackle/pggit/postgresql/src/backend/utils/adt/ri_triggers.c
- ri_BuildQueryKey(&qkey, riinfo, RI_PLAN_CHECK_LOOKUPPK);
- if ((qplan = ri_FetchPreparedPlan(&qkey)) == NULL)
- {
- StringInfoData querybuf;
- char pkrelname[MAX_QUOTED_REL_NAME_LEN];
- char attname[MAX_QUOTED_NAME_LEN];
- char paramname[16];
- const char *querysep;
- Oid queryoids[RI_MAX_NUMKEYS];
- /* ----------
- * The query string built is
- * SELECT 1 FROM ONLY <pktable> x WHERE pkatt1 = $1 [AND ...]
- * FOR KEY SHARE OF x
- * The type id's for the $ parameters are those of the
- * corresponding FK attributes.
- * ----------
- */
- initStringInfo(&querybuf);
- quoteRelationName(pkrelname, pk_rel);
- appendStringInfo(&querybuf, "SELECT 1 FROM ONLY %s x", pkrelname);
- querysep = "WHERE";
- for (i = 0; i < riinfo->nkeys; i++)
- {
- Oid pk_type = RIAttType(pk_rel, riinfo->pk_attnums[i]);
- =====================================================================
- Found a 22 line (106 tokens) duplication in the following files:
- Starting at line 459 of /home/shackle/pggit/postgresql/contrib/ltree/ltxtquery_io.c
- Starting at line 585 of /home/shackle/pggit/postgresql/contrib/intarray/_int_bool.c
- in->curpol++;
- if (in->curpol->type == OPR)
- {
- isopr = true;
- RESIZEBUF(in, 2);
- sprintf(in->cur, "( ");
- in->cur = strchr(in->cur, '\0');
- }
- infix(in, isopr);
- if (isopr)
- {
- RESIZEBUF(in, 2);
- sprintf(in->cur, " )");
- in->cur = strchr(in->cur, '\0');
- }
- }
- else
- {
- int32 op = in->curpol->val;
- INFIX nrm;
- in->curpol++;
- =====================================================================
- Found a 18 line (106 tokens) duplication in the following files:
- Starting at line 136 of /home/shackle/pggit/postgresql/contrib/ltree/_ltree_op.c
- Starting at line 341 of /home/shackle/pggit/postgresql/contrib/ltree/lquery_op.c
- ArrayType *_tree = PG_GETARG_ARRAYTYPE_P(0);
- ArrayType *_query = PG_GETARG_ARRAYTYPE_P(1);
- lquery *query = (lquery *) ARR_DATA_PTR(_query);
- bool res = false;
- int num = ArrayGetNItems(ARR_NDIM(_query), ARR_DIMS(_query));
- if (ARR_NDIM(_query) > 1)
- ereport(ERROR,
- (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
- errmsg("array must be one-dimensional")));
- if (array_contains_nulls(_query))
- ereport(ERROR,
- (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
- errmsg("array must not contain nulls")));
- while (num > 0)
- {
- if (array_iterator(_tree, ltq_regex, (void *) query, NULL))
- =====================================================================
- Found a 47 line (106 tokens) duplication in the following files:
- Starting at line 348 of /home/shackle/pggit/postgresql/contrib/tsm_system_rows/tsm_system_rows.c
- Starting at line 309 of /home/shackle/pggit/postgresql/contrib/tsm_system_time/tsm_system_time.c
- return false;
- }
- /*
- * Compute greatest common divisor of two uint32's.
- */
- static uint32
- gcd(uint32 a, uint32 b)
- {
- uint32 c;
- while (a != 0)
- {
- c = a;
- a = b % a;
- b = c;
- }
- return b;
- }
- /*
- * Pick a random value less than and relatively prime to n, if possible
- * (else return 1).
- */
- static uint32
- random_relative_prime(uint32 n, SamplerRandomState randstate)
- {
- uint32 r;
- /* Safety check to avoid infinite loop or zero result for small n. */
- if (n <= 1)
- return 1;
- /*
- * This should only take 2 or 3 iterations as the probability of 2 numbers
- * being relatively prime is ~61%; but just in case, we'll include a
- * CHECK_FOR_INTERRUPTS in the loop.
- */
- do
- {
- CHECK_FOR_INTERRUPTS();
- r = (uint32) (sampler_random_fract(randstate) * n);
- } while (r == 0 || gcd(r, n) > 1);
- return r;
- }
- =====================================================================
- Found a 32 line (106 tokens) duplication in the following files:
- Starting at line 917 of /home/shackle/pggit/postgresql/src/bin/pg_dump/dumputils.c
- Starting at line 3298 of /home/shackle/pggit/postgresql/src/backend/utils/adt/varlena.c
- while (isspace((unsigned char) *nextp))
- nextp++; /* skip leading whitespace */
- if (*nextp == '\0')
- return true; /* allow empty string */
- /* At the top of the loop, we are at start of a new identifier. */
- do
- {
- char *curname;
- char *endp;
- if (*nextp == '"')
- {
- /* Quoted name --- collapse quote-quote pairs */
- curname = nextp + 1;
- for (;;)
- {
- endp = strchr(nextp + 1, '"');
- if (endp == NULL)
- return false; /* mismatched quotes */
- if (endp[1] != '"')
- break; /* found end of quoted name */
- /* Collapse adjacent quotes into one quote, and look again */
- memmove(endp, endp + 1, strlen(endp));
- nextp = endp;
- }
- /* endp now points at the terminating quote */
- nextp = endp + 1;
- }
- else
- {
- =====================================================================
- Found a 22 line (106 tokens) duplication in the following files:
- Starting at line 415 of /home/shackle/pggit/postgresql/src/pl/plpgsql/src/pl_handler.c
- Starting at line 1989 of /home/shackle/pggit/postgresql/src/pl/plperl/plperl.c
- bool is_dml_trigger = false;
- bool is_event_trigger = false;
- int i;
- if (!CheckFunctionValidatorAccess(fcinfo->flinfo->fn_oid, funcoid))
- PG_RETURN_VOID();
- /* Get the new function's pg_proc entry */
- tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcoid));
- if (!HeapTupleIsValid(tuple))
- elog(ERROR, "cache lookup failed for function %u", funcoid);
- proc = (Form_pg_proc) GETSTRUCT(tuple);
- functyptype = get_typtype(proc->prorettype);
- /* Disallow pseudotype result */
- /* except for TRIGGER, RECORD, VOID, or polymorphic */
- if (functyptype == TYPTYPE_PSEUDO)
- {
- /* we assume OPAQUE with no arguments means a trigger */
- if (proc->prorettype == TRIGGEROID ||
- (proc->prorettype == OPAQUEOID && proc->pronargs == 0))
- =====================================================================
- Found a 23 line (106 tokens) duplication in the following files:
- Starting at line 678 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/interval.c
- Starting at line 4185 of /home/shackle/pggit/postgresql/src/backend/utils/adt/datetime.c
- return 0;
- }
- /* copy&pasted from .../src/backend/utils/adt/datetime.c */
- static char *
- AddVerboseIntPart(char *cp, int value, const char *units,
- bool *is_zero, bool *is_before)
- {
- if (value == 0)
- return cp;
- /* first nonzero value sets is_before */
- if (*is_zero)
- {
- *is_before = (value < 0);
- value = abs(value);
- }
- else if (*is_before)
- value = -value;
- sprintf(cp, " %d %s%s", value, units, (value == 1) ? "" : "s");
- *is_zero = false;
- return cp + strlen(cp);
- }
- =====================================================================
- Found a 11 line (106 tokens) duplication in the following files:
- Starting at line 313 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-desc.c
- Starting at line 332 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-desc.c
- { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch next from c2", ECPGt_EOIT,
- ECPGt_int,&(val1output),(long)1,(long)1,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_char,(val2output),(long)sizeof("AAA"),(long)1,(sizeof("AAA"))*sizeof(char),
- ECPGt_int,&(val2i),(long)1,(long)1,sizeof(int), ECPGt_EORT);
- #line 73 "desc.pgc"
- if (sqlca.sqlcode < 0) sqlprint();}
- #line 73 "desc.pgc"
- printf("val1=%d val2=%s\n", val1output, val2i ? "null" : val2output);
- =====================================================================
- Found a 19 line (106 tokens) duplication in the following files:
- Starting at line 731 of /home/shackle/pggit/postgresql/src/backend/storage/page/bufpage.c
- Starting at line 960 of /home/shackle/pggit/postgresql/src/backend/storage/page/bufpage.c
- int offidx;
- int nline;
- /*
- * As with PageRepairFragmentation, paranoia seems justified.
- */
- if (phdr->pd_lower < SizeOfPageHeaderData ||
- phdr->pd_lower > phdr->pd_upper ||
- phdr->pd_upper > phdr->pd_special ||
- phdr->pd_special > BLCKSZ ||
- phdr->pd_special != MAXALIGN(phdr->pd_special))
- ereport(ERROR,
- (errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("corrupted page pointers: lower = %u, upper = %u, special = %u",
- phdr->pd_lower, phdr->pd_upper, phdr->pd_special)));
- nline = PageGetMaxOffsetNumber(page);
- if ((int) offnum <= 0 || (int) offnum > nline)
- elog(ERROR, "invalid index offnum: %u", offnum);
- =====================================================================
- Found a 17 line (106 tokens) duplication in the following files:
- Starting at line 1079 of /home/shackle/pggit/postgresql/src/backend/regex/regexec.c
- Starting at line 1280 of /home/shackle/pggit/postgresql/src/backend/regex/regexec.c
- max_matches = end - begin;
- if (max_matches > t->max && t->max != DUPINF)
- max_matches = t->max;
- if (max_matches < min_matches)
- max_matches = min_matches;
- endpts = (chr **) MALLOC((max_matches + 1) * sizeof(chr *));
- if (endpts == NULL)
- return REG_ESPACE;
- endpts[0] = begin;
- d = getsubdfa(v, t->left);
- if (ISERR())
- {
- FREE(endpts);
- return v->err;
- }
- MDEBUG(("citer %d\n", t->id));
- =====================================================================
- Found a 5 line (106 tokens) duplication in the following files:
- Starting at line 98 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
- Starting at line 103 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- =====================================================================
- Found a 23 line (106 tokens) duplication in the following files:
- Starting at line 69 of /home/shackle/pggit/postgresql/src/backend/commands/policy.c
- Starting at line 13368 of /home/shackle/pggit/postgresql/src/backend/commands/tablecmds.c
- Form_pg_class classform;
- char relkind;
- tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
- if (!HeapTupleIsValid(tuple))
- return;
- classform = (Form_pg_class) GETSTRUCT(tuple);
- relkind = classform->relkind;
- /* Must own relation. */
- if (!pg_class_ownercheck(relid, GetUserId()))
- aclcheck_error(ACLCHECK_NOT_OWNER, get_relkind_objtype(get_rel_relkind(relid)), rv->relname);
- /* No system table modifications unless explicitly allowed. */
- if (!allowSystemTableMods && IsSystemClass(relid, classform))
- ereport(ERROR,
- (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
- errmsg("permission denied: \"%s\" is a system catalog",
- rv->relname)));
- /* Relation type MUST be a table. */
- if (relkind != RELKIND_RELATION && relkind != RELKIND_PARTITIONED_TABLE)
- =====================================================================
- Found a 16 line (105 tokens) duplication in the following files:
- Starting at line 146 of /home/shackle/pggit/postgresql/contrib/jsonb_plpython/jsonb_plpython.c
- Starting at line 68 of /home/shackle/pggit/postgresql/contrib/jsonb_plperl/jsonb_plperl.c
- PyObject *result;
- it = JsonbIteratorInit(jsonb);
- r = JsonbIteratorNext(&it, &v, true);
- switch (r)
- {
- case WJB_BEGIN_ARRAY:
- if (v.val.array.rawScalar)
- {
- JsonbValue tmp;
- if ((r = JsonbIteratorNext(&it, &v, true)) != WJB_ELEM ||
- (r = JsonbIteratorNext(&it, &tmp, true)) != WJB_END_ARRAY ||
- (r = JsonbIteratorNext(&it, &tmp, true)) != WJB_DONE)
- elog(ERROR, "unexpected jsonb token: %d", r);
- =====================================================================
- Found a 20 line (105 tokens) duplication in the following files:
- Starting at line 139 of /home/shackle/pggit/postgresql/src/pl/plpython/plpy_resultobject.c
- Starting at line 165 of /home/shackle/pggit/postgresql/src/pl/plpython/plpy_resultobject.c
- PLy_result_coltypes(PyObject *self, PyObject *unused)
- {
- PLyResultObject *ob = (PLyResultObject *) self;
- PyObject *list;
- int i;
- if (!ob->tupdesc)
- {
- PLy_exception_set(PLy_exc_error, "command did not produce a result set");
- return NULL;
- }
- list = PyList_New(ob->tupdesc->natts);
- if (!list)
- return NULL;
- for (i = 0; i < ob->tupdesc->natts; i++)
- {
- Form_pg_attribute attr = TupleDescAttr(ob->tupdesc, i);
- PyList_SET_ITEM(list, i, PyInt_FromLong(attr->atttypid));
- =====================================================================
- Found a 3 line (105 tokens) duplication in the following files:
- Starting at line 31 of /home/shackle/pggit/postgresql/src/common/base64.c
- Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
- Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 207 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
- =====================================================================
- Found a 3 line (105 tokens) duplication in the following files:
- Starting at line 31 of /home/shackle/pggit/postgresql/src/common/base64.c
- Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
- Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 207 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
- =====================================================================
- Found a 30 line (105 tokens) duplication in the following files:
- Starting at line 5577 of /home/shackle/pggit/postgresql/src/backend/catalog/aclchk.c
- Starting at line 5863 of /home/shackle/pggit/postgresql/src/backend/catalog/aclchk.c
- bool isNull;
- HeapTuple tuple;
- tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(objoid));
- if (!HeapTupleIsValid(tuple))
- elog(ERROR, "cache lookup failed for relation %u", objoid);
- pg_class_tuple = (Form_pg_class) GETSTRUCT(tuple);
- /* Indexes don't have permissions */
- if (pg_class_tuple->relkind == RELKIND_INDEX ||
- pg_class_tuple->relkind == RELKIND_PARTITIONED_INDEX)
- return;
- /* Composite types don't have permissions either */
- if (pg_class_tuple->relkind == RELKIND_COMPOSITE_TYPE)
- return;
- /*
- * If this isn't a sequence, index, or composite type then it's
- * possibly going to have columns associated with it that might have
- * ACLs.
- */
- if (pg_class_tuple->relkind != RELKIND_SEQUENCE)
- {
- AttrNumber curr_att;
- AttrNumber nattrs = pg_class_tuple->relnatts;
- for (curr_att = 1; curr_att <= nattrs; curr_att++)
- {
- HeapTuple attTuple;
- =====================================================================
- Found a 29 line (105 tokens) duplication in the following files:
- Starting at line 3625 of /home/shackle/pggit/postgresql/src/backend/utils/adt/numeric.c
- Starting at line 3712 of /home/shackle/pggit/postgresql/src/backend/utils/adt/numeric.c
- accum_sum_copy(&state1->sumX2, &state2->sumX2);
- MemoryContextSwitchTo(old_context);
- PG_RETURN_POINTER(state1);
- }
- if (state2->N > 0)
- {
- state1->N += state2->N;
- state1->NaNcount += state2->NaNcount;
- /*
- * These are currently only needed for moving aggregates, but let's do
- * the right thing anyway...
- */
- if (state2->maxScale > state1->maxScale)
- {
- state1->maxScale = state2->maxScale;
- state1->maxScaleCount = state2->maxScaleCount;
- }
- else if (state2->maxScale == state1->maxScale)
- state1->maxScaleCount += state2->maxScaleCount;
- /* The rest of this needs to work in the aggregate context */
- old_context = MemoryContextSwitchTo(agg_context);
- /* Accumulate sums */
- accum_sum_combine(&state1->sumX, &state2->sumX);
- =====================================================================
- Found a 14 line (105 tokens) duplication in the following files:
- Starting at line 1244 of /home/shackle/pggit/postgresql/src/backend/utils/adt/timestamp.c
- Starting at line 681 of /home/shackle/pggit/postgresql/src/backend/utils/adt/varbit.c
- interval_transform(PG_FUNCTION_ARGS)
- {
- FuncExpr *expr = castNode(FuncExpr, PG_GETARG_POINTER(0));
- Node *ret = NULL;
- Node *typmod;
- Assert(list_length(expr->args) >= 2);
- typmod = (Node *) lsecond(expr->args);
- if (IsA(typmod, Const) &&!((Const *) typmod)->constisnull)
- {
- Node *source = (Node *) linitial(expr->args);
- int32 new_typmod = DatumGetInt32(((Const *) typmod)->constvalue);
- =====================================================================
- Found a 32 line (105 tokens) duplication in the following files:
- Starting at line 4547 of /home/shackle/pggit/postgresql/src/backend/utils/adt/timestamp.c
- Starting at line 4935 of /home/shackle/pggit/postgresql/src/backend/utils/adt/timestamp.c
- switch (val)
- {
- case DTK_MICROSEC:
- result = tm->tm_sec * 1000000.0 + fsec;
- break;
- case DTK_MILLISEC:
- result = tm->tm_sec * 1000.0 + fsec / 1000.0;
- break;
- case DTK_SECOND:
- result = tm->tm_sec + fsec / 1000000.0;
- break;
- case DTK_MINUTE:
- result = tm->tm_min;
- break;
- case DTK_HOUR:
- result = tm->tm_hour;
- break;
- case DTK_DAY:
- result = tm->tm_mday;
- break;
- case DTK_MONTH:
- result = tm->tm_mon;
- break;
- case DTK_QUARTER:
- result = (tm->tm_mon - 1) / 3 + 1;
- =====================================================================
- Found a 24 line (105 tokens) duplication in the following files:
- Starting at line 3241 of /home/shackle/pggit/postgresql/src/backend/utils/adt/varlena.c
- Starting at line 1695 of /home/shackle/pggit/postgresql/src/backend/utils/adt/regproc.c
- rawname = text_to_cstring(textval);
- if (!SplitIdentifierString(rawname, '.', &namelist))
- ereport(ERROR,
- (errcode(ERRCODE_INVALID_NAME),
- errmsg("invalid name syntax")));
- if (namelist == NIL)
- ereport(ERROR,
- (errcode(ERRCODE_INVALID_NAME),
- errmsg("invalid name syntax")));
- foreach(l, namelist)
- {
- char *curname = (char *) lfirst(l);
- result = lappend(result, makeString(pstrdup(curname)));
- }
- pfree(rawname);
- list_free(namelist);
- return result;
- }
- =====================================================================
- Found a 27 line (105 tokens) duplication in the following files:
- Starting at line 847 of /home/shackle/pggit/postgresql/src/backend/access/heap/tuptoaster.c
- Starting at line 961 of /home/shackle/pggit/postgresql/src/backend/access/heap/tuptoaster.c
- if (att->attstorage != 'x' && att->attstorage != 'e')
- continue;
- if (toast_sizes[i] > biggest_size)
- {
- biggest_attno = i;
- biggest_size = toast_sizes[i];
- }
- }
- if (biggest_attno < 0)
- break;
- /*
- * Store this external
- */
- i = biggest_attno;
- old_value = toast_values[i];
- toast_action[i] = 'p';
- toast_values[i] = toast_save_datum(rel, toast_values[i],
- toast_oldexternal[i], options);
- if (toast_free[i])
- pfree(DatumGetPointer(old_value));
- toast_free[i] = true;
- need_change = true;
- need_free = true;
- }
- =====================================================================
- Found a 17 line (104 tokens) duplication in the following files:
- Starting at line 520 of /home/shackle/pggit/postgresql/contrib/ltree/_ltree_gist.c
- Starting at line 582 of /home/shackle/pggit/postgresql/contrib/ltree/ltree_gist.c
- _arrq_cons(ltree_gist *key, ArrayType *_query)
- {
- lquery *query = (lquery *) ARR_DATA_PTR(_query);
- int num = ArrayGetNItems(ARR_NDIM(_query), ARR_DIMS(_query));
- if (ARR_NDIM(_query) > 1)
- ereport(ERROR,
- (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
- errmsg("array must be one-dimensional")));
- if (array_contains_nulls(_query))
- ereport(ERROR,
- (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
- errmsg("array must not contain nulls")));
- while (num > 0)
- {
- if (gist_qe(key, query))
- =====================================================================
- Found a 20 line (104 tokens) duplication in the following files:
- Starting at line 880 of /home/shackle/pggit/postgresql/contrib/pg_trgm/trgm_gist.c
- Starting at line 222 of /home/shackle/pggit/postgresql/src/backend/utils/adt/tsquery_gist.c
- size_beta = hemdistcache(&(cache[seed_2]), &(cache[j]));
- costvector[j - 1].cost = abs(size_alpha - size_beta);
- }
- qsort((void *) costvector, maxoff, sizeof(SPLITCOST), comparecost);
- for (k = 0; k < maxoff; k++)
- {
- j = costvector[k].pos;
- if (j == seed_1)
- {
- *left++ = j;
- v->spl_nleft++;
- continue;
- }
- else if (j == seed_2)
- {
- *right++ = j;
- v->spl_nright++;
- continue;
- }
- =====================================================================
- Found a 24 line (104 tokens) duplication in the following files:
- Starting at line 1174 of /home/shackle/pggit/postgresql/contrib/pgcrypto/imath.c
- Starting at line 1212 of /home/shackle/pggit/postgresql/contrib/pgcrypto/imath.c
- if ((res = mp_int_init_copy(&t, a)) != MP_OK)
- return res;
- (void) mp_int_set_value(c, 1);
- while (v != 0)
- {
- if (v & 1)
- {
- if ((res = mp_int_mul(c, &t, c)) != MP_OK)
- goto CLEANUP;
- }
- v >>= 1;
- if (v == 0)
- break;
- if ((res = mp_int_sqr(&t, &t)) != MP_OK)
- goto CLEANUP;
- }
- CLEANUP:
- mp_int_clear(&t);
- return res;
- }
- =====================================================================
- Found a 21 line (104 tokens) duplication in the following files:
- Starting at line 82 of /home/shackle/pggit/postgresql/src/bin/scripts/vacuumdb.c
- Starting at line 31 of /home/shackle/pggit/postgresql/src/bin/scripts/reindexdb.c
- Starting at line 25 of /home/shackle/pggit/postgresql/src/bin/scripts/clusterdb.c
- static void init_slot(ParallelSlot *slot, PGconn *conn);
- static void help(const char *progname);
- /* For analyze-in-stages mode */
- #define ANALYZE_NO_STAGE -1
- #define ANALYZE_NUM_STAGES 3
- int
- main(int argc, char *argv[])
- {
- static struct option long_options[] = {
- {"host", required_argument, NULL, 'h'},
- {"port", required_argument, NULL, 'p'},
- {"username", required_argument, NULL, 'U'},
- {"no-password", no_argument, NULL, 'w'},
- {"password", no_argument, NULL, 'W'},
- {"echo", no_argument, NULL, 'e'},
- {"quiet", no_argument, NULL, 'q'},
- {"dbname", required_argument, NULL, 'd'},
- =====================================================================
- Found a 23 line (104 tokens) duplication in the following files:
- Starting at line 4646 of /home/shackle/pggit/postgresql/src/pl/plpgsql/src/pl_exec.c
- Starting at line 4734 of /home/shackle/pggit/postgresql/src/pl/plpgsql/src/pl_exec.c
- uint64 n;
- MemoryContext oldcontext;
- /* ----------
- * Get the portal of the cursor by name
- * ----------
- */
- curvar = (PLpgSQL_var *) (estate->datums[stmt->curvar]);
- if (curvar->isnull)
- ereport(ERROR,
- (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
- errmsg("cursor variable \"%s\" is null", curvar->refname)));
- /* Use eval_mcontext for short-lived string */
- oldcontext = MemoryContextSwitchTo(get_eval_mcontext(estate));
- curname = TextDatumGetCString(curvar->value);
- MemoryContextSwitchTo(oldcontext);
- portal = SPI_cursor_find(curname);
- if (portal == NULL)
- ereport(ERROR,
- (errcode(ERRCODE_UNDEFINED_CURSOR),
- errmsg("cursor \"%s\" does not exist", curname)));
- =====================================================================
- Found a 29 line (104 tokens) duplication in the following files:
- Starting at line 32 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/ecpglib/misc.c
- Starting at line 21 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/compatlib/informix.c
- static struct sqlca_t sqlca_init =
- {
- {
- 'S', 'Q', 'L', 'C', 'A', ' ', ' ', ' '
- },
- sizeof(struct sqlca_t),
- 0,
- {
- 0,
- {
- 0
- }
- },
- {
- 'N', 'O', 'T', ' ', 'S', 'E', 'T', ' '
- },
- {
- 0, 0, 0, 0, 0, 0
- },
- {
- 0, 0, 0, 0, 0, 0, 0, 0
- },
- {
- '0', '0', '0', '0', '0'
- }
- };
- #ifdef ENABLE_THREAD_SAFETY
- static pthread_key_t sqlca_key;
- =====================================================================
- Found a 21 line (104 tokens) duplication in the following files:
- Starting at line 114 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-oldexec.c
- Starting at line 113 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-execute.c
- { ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_execute, "i",
- ECPGt_int,&(increment),(long)1,(long)1,sizeof(int),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
- #line 42 "oldexec.pgc"
- if (sqlca.sqlcode < 0) sqlprint();}
- #line 42 "oldexec.pgc"
- printf("Inserted %ld tuples via prepared execute\n", sqlca.sqlerrd[2]);
- { ECPGtrans(__LINE__, NULL, "commit");
- #line 46 "oldexec.pgc"
- if (sqlca.sqlcode < 0) sqlprint();}
- #line 46 "oldexec.pgc"
- sprintf (command, "select * from test");
- { ECPGprepare(__LINE__, NULL, 1, "f", command);
- =====================================================================
- Found a 5 line (104 tokens) duplication in the following files:
- Starting at line 98 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
- Starting at line 103 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- =====================================================================
- Found a 20 line (103 tokens) duplication in the following files:
- Starting at line 1380 of /home/shackle/pggit/postgresql/contrib/hstore/hstore_io.c
- Starting at line 1426 of /home/shackle/pggit/postgresql/contrib/hstore/hstore_io.c
- JsonbValue *res;
- (void) pushJsonbValue(&state, WJB_BEGIN_OBJECT, NULL);
- for (i = 0; i < count; i++)
- {
- JsonbValue key,
- val;
- key.type = jbvString;
- key.val.string.len = HSTORE_KEYLEN(entries, i);
- key.val.string.val = HSTORE_KEY(entries, base, i);
- (void) pushJsonbValue(&state, WJB_KEY, &key);
- if (HSTORE_VALISNULL(entries, i))
- {
- val.type = jbvNull;
- }
- else
- =====================================================================
- Found a 42 line (103 tokens) duplication in the following files:
- Starting at line 3184 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-connect.c
- Starting at line 3252 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-connect.c
- return PGRES_POLLING_WRITING;
- }
- /*
- * If a read-write connection is required, see if we have one.
- *
- * Servers before 7.4 lack the transaction_read_only GUC, but
- * by the same token they don't have any read-only mode, so we
- * may just skip the test in that case.
- */
- if (conn->sversion >= 70400 &&
- conn->target_session_attrs != NULL &&
- strcmp(conn->target_session_attrs, "read-write") == 0)
- {
- /*
- * Save existing error messages across the PQsendQuery
- * attempt. This is necessary because PQsendQuery is
- * going to reset conn->errorMessage, so we would lose
- * error messages related to previous hosts we have tried
- * and failed to connect to.
- */
- if (!saveErrorMessage(conn, &savedMessage))
- goto error_return;
- conn->status = CONNECTION_OK;
- if (!PQsendQuery(conn,
- "SHOW transaction_read_only"))
- {
- restoreErrorMessage(conn, &savedMessage);
- goto error_return;
- }
- conn->status = CONNECTION_CHECK_WRITABLE;
- restoreErrorMessage(conn, &savedMessage);
- return PGRES_POLLING_READING;
- }
- /* We can release the address list now. */
- release_conn_addrinfo(conn);
- /* We are open for business! */
- conn->status = CONNECTION_OK;
- return PGRES_POLLING_OK;
- =====================================================================
- Found a 16 line (103 tokens) duplication in the following files:
- Starting at line 1186 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
- Starting at line 1490 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
- InitFunctionCallInfoData(fcinfo, flinfo, 4, collation, NULL, NULL);
- fcinfo.arg[0] = arg1;
- fcinfo.arg[1] = arg2;
- fcinfo.arg[2] = arg3;
- fcinfo.arg[3] = arg4;
- fcinfo.argnull[0] = false;
- fcinfo.argnull[1] = false;
- fcinfo.argnull[2] = false;
- fcinfo.argnull[3] = false;
- result = FunctionCallInvoke(&fcinfo);
- /* Check for null result, since caller is clearly not expecting one */
- if (fcinfo.isnull)
- elog(ERROR, "function %u returned NULL", fcinfo.flinfo->fn_oid);
- =====================================================================
- Found a 29 line (103 tokens) duplication in the following files:
- Starting at line 773 of /home/shackle/pggit/postgresql/src/backend/utils/mmgr/mcxt.c
- Starting at line 959 of /home/shackle/pggit/postgresql/src/backend/utils/mmgr/mcxt.c
- void *ret;
- AssertArg(MemoryContextIsValid(context));
- AssertNotInCriticalSection(context);
- if (!AllocSizeIsValid(size))
- elog(ERROR, "invalid memory alloc request size %zu", size);
- context->isReset = false;
- ret = context->methods->alloc(context, size);
- if (unlikely(ret == NULL))
- {
- MemoryContextStats(TopMemoryContext);
- /*
- * Here, and elsewhere in this module, we show the target context's
- * "name" but not its "ident" (if any) in user-visible error messages.
- * The "ident" string might contain security-sensitive data, such as
- * values in SQL commands.
- */
- ereport(ERROR,
- (errcode(ERRCODE_OUT_OF_MEMORY),
- errmsg("out of memory"),
- errdetail("Failed on request of size %zu in memory context \"%s\".",
- size, context->name)));
- }
- VALGRIND_MEMPOOL_ALLOC(context, ret, size);
- =====================================================================
- Found a 22 line (103 tokens) duplication in the following files:
- Starting at line 816 of /home/shackle/pggit/postgresql/src/backend/utils/mmgr/mcxt.c
- Starting at line 854 of /home/shackle/pggit/postgresql/src/backend/utils/mmgr/mcxt.c
- Starting at line 928 of /home/shackle/pggit/postgresql/src/backend/utils/mmgr/mcxt.c
- void *ret;
- AssertArg(MemoryContextIsValid(context));
- AssertNotInCriticalSection(context);
- if (!AllocSizeIsValid(size))
- elog(ERROR, "invalid memory alloc request size %zu", size);
- context->isReset = false;
- ret = context->methods->alloc(context, size);
- if (unlikely(ret == NULL))
- {
- MemoryContextStats(TopMemoryContext);
- ereport(ERROR,
- (errcode(ERRCODE_OUT_OF_MEMORY),
- errmsg("out of memory"),
- errdetail("Failed on request of size %zu in memory context \"%s\".",
- size, context->name)));
- }
- VALGRIND_MEMPOOL_ALLOC(context, ret, size);
- =====================================================================
- Found a 22 line (103 tokens) duplication in the following files:
- Starting at line 102 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conv.c
- Starting at line 249 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conv.c
- int c1;
- while (len > 0)
- {
- c1 = *mic;
- if (c1 == 0)
- report_invalid_encoding(PG_MULE_INTERNAL, (const char *) mic, len);
- if (!IS_HIGHBIT_SET(c1))
- {
- /* easy for ASCII */
- *p++ = c1;
- mic++;
- len--;
- }
- else
- {
- int l = pg_mic_mblen(mic);
- if (len < l)
- report_invalid_encoding(PG_MULE_INTERNAL, (const char *) mic,
- len);
- if (l != 2 || c1 != lc || !IS_HIGHBIT_SET(mic[1]))
- =====================================================================
- Found a 16 line (103 tokens) duplication in the following files:
- Starting at line 3590 of /home/shackle/pggit/postgresql/src/backend/utils/adt/formatting.c
- Starting at line 3622 of /home/shackle/pggit/postgresql/src/backend/utils/adt/formatting.c
- if (timestamp2tm(dt, NULL, tm, &tmtcFsec(&tmtc), NULL, NULL) != 0)
- ereport(ERROR,
- (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
- errmsg("timestamp out of range")));
- thisdate = date2j(tm->tm_year, tm->tm_mon, tm->tm_mday);
- tm->tm_wday = (thisdate + 1) % 7;
- tm->tm_yday = thisdate - date2j(tm->tm_year, 1, 1) + 1;
- if (!(res = datetime_to_char_body(&tmtc, fmt, false, PG_GET_COLLATION())))
- PG_RETURN_NULL();
- PG_RETURN_TEXT_P(res);
- }
- Datum
- =====================================================================
- Found a 22 line (103 tokens) duplication in the following files:
- Starting at line 4194 of /home/shackle/pggit/postgresql/src/backend/utils/adt/numeric.c
- Starting at line 4425 of /home/shackle/pggit/postgresql/src/backend/utils/adt/numeric.c
- numeric_poly_combine(PG_FUNCTION_ARGS)
- {
- PolyNumAggState *state1;
- PolyNumAggState *state2;
- MemoryContext agg_context;
- MemoryContext old_context;
- if (!AggCheckCallContext(fcinfo, &agg_context))
- elog(ERROR, "aggregate function called in non-aggregate context");
- state1 = PG_ARGISNULL(0) ? NULL : (PolyNumAggState *) PG_GETARG_POINTER(0);
- state2 = PG_ARGISNULL(1) ? NULL : (PolyNumAggState *) PG_GETARG_POINTER(1);
- if (state2 == NULL)
- PG_RETURN_POINTER(state1);
- /* manually copy all fields from state2 to state1 */
- if (state1 == NULL)
- {
- old_context = MemoryContextSwitchTo(agg_context);
- state1 = makePolyNumAggState(fcinfo, true);
- =====================================================================
- Found a 31 line (103 tokens) duplication in the following files:
- Starting at line 2935 of /home/shackle/pggit/postgresql/src/backend/utils/adt/float.c
- Starting at line 3073 of /home/shackle/pggit/postgresql/src/backend/utils/adt/float.c
- PG_RETURN_ARRAYTYPE_P(transarray);
- }
- else
- {
- Datum transdatums[6];
- ArrayType *result;
- transdatums[0] = Float8GetDatumFast(N);
- transdatums[1] = Float8GetDatumFast(Sx);
- transdatums[2] = Float8GetDatumFast(Sxx);
- transdatums[3] = Float8GetDatumFast(Sy);
- transdatums[4] = Float8GetDatumFast(Syy);
- transdatums[5] = Float8GetDatumFast(Sxy);
- result = construct_array(transdatums, 6,
- FLOAT8OID,
- sizeof(float8), FLOAT8PASSBYVAL, 'd');
- PG_RETURN_ARRAYTYPE_P(result);
- }
- }
- /*
- * float8_regr_combine
- *
- * An aggregate combine function used to combine two 6 fields
- * aggregate transition data into a single transition data.
- * This function is used only in two stage aggregation and
- * shouldn't be called outside aggregate context.
- */
- Datum
- =====================================================================
- Found a 21 line (103 tokens) duplication in the following files:
- Starting at line 824 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rangetypes.c
- Starting at line 911 of /home/shackle/pggit/postgresql/src/backend/utils/adt/rangetypes.c
- range_overlaps_internal(TypeCacheEntry *typcache, RangeType *r1, RangeType *r2)
- {
- RangeBound lower1,
- lower2;
- RangeBound upper1,
- upper2;
- bool empty1,
- empty2;
- /* Different types should be prevented by ANYRANGE matching rules */
- if (RangeTypeGetOid(r1) != RangeTypeGetOid(r2))
- elog(ERROR, "range types do not match");
- range_deserialize(typcache, r1, &lower1, &upper1, &empty1);
- range_deserialize(typcache, r2, &lower2, &upper2, &empty2);
- /* An empty range does not overlap any other range */
- if (empty1 || empty2)
- return false;
- if (range_cmp_bounds(typcache, &lower1, &lower2) >= 0 &&
- =====================================================================
- Found a 22 line (103 tokens) duplication in the following files:
- Starting at line 421 of /home/shackle/pggit/postgresql/src/backend/utils/adt/geo_ops.c
- Starting at line 466 of /home/shackle/pggit/postgresql/src/backend/utils/adt/geo_ops.c
- path_decode(str, false, 2, &(box->high), &isopen, NULL, "box", str);
- /* reorder corners if necessary... */
- if (float8_lt(box->high.x, box->low.x))
- {
- x = box->high.x;
- box->high.x = box->low.x;
- box->low.x = x;
- }
- if (float8_lt(box->high.y, box->low.y))
- {
- y = box->high.y;
- box->high.y = box->low.y;
- box->low.y = y;
- }
- PG_RETURN_BOX_P(box);
- }
- /* box_out - convert a box to external form.
- */
- Datum
- =====================================================================
- Found a 15 line (103 tokens) duplication in the following files:
- Starting at line 10675 of /home/shackle/pggit/postgresql/src/backend/commands/tablecmds.c
- Starting at line 10732 of /home/shackle/pggit/postgresql/src/backend/commands/tablecmds.c
- memset(repl_val, 0, sizeof(repl_val));
- memset(repl_null, false, sizeof(repl_null));
- memset(repl_repl, false, sizeof(repl_repl));
- if (newOptions != (Datum) 0)
- repl_val[Anum_pg_class_reloptions - 1] = newOptions;
- else
- repl_null[Anum_pg_class_reloptions - 1] = true;
- repl_repl[Anum_pg_class_reloptions - 1] = true;
- newtuple = heap_modify_tuple(tuple, RelationGetDescr(pgclass),
- repl_val, repl_null, repl_repl);
- CatalogTupleUpdate(pgclass, &newtuple->t_self, newtuple);
- =====================================================================
- Found a 24 line (102 tokens) duplication in the following files:
- Starting at line 17 of /home/shackle/pggit/postgresql/contrib/hstore_plpython/hstore_plpython.c
- Starting at line 12 of /home/shackle/pggit/postgresql/contrib/hstore_plperl/hstore_plperl.c
- static PLyUnicode_FromStringAndSize_t PLyUnicode_FromStringAndSize_p;
- #endif
- /* Linkage to functions in hstore module */
- typedef HStore *(*hstoreUpgrade_t) (Datum orig);
- static hstoreUpgrade_t hstoreUpgrade_p;
- typedef int (*hstoreUniquePairs_t) (Pairs *a, int32 l, int32 *buflen);
- static hstoreUniquePairs_t hstoreUniquePairs_p;
- typedef HStore *(*hstorePairs_t) (Pairs *pairs, int32 pcount, int32 buflen);
- static hstorePairs_t hstorePairs_p;
- typedef size_t (*hstoreCheckKeyLen_t) (size_t len);
- static hstoreCheckKeyLen_t hstoreCheckKeyLen_p;
- typedef size_t (*hstoreCheckValLen_t) (size_t len);
- static hstoreCheckValLen_t hstoreCheckValLen_p;
- /*
- * Module initialize function: fetch function pointers for cross-module calls.
- */
- void
- _PG_init(void)
- {
- /* Asserts verify that typedefs above match original declarations */
- AssertVariableIsOfType(&PLyObject_AsString, PLyObject_AsString_t);
- =====================================================================
- Found a 21 line (102 tokens) duplication in the following files:
- Starting at line 287 of /home/shackle/pggit/postgresql/contrib/hstore/hstore_gist.c
- Starting at line 280 of /home/shackle/pggit/postgresql/contrib/intarray/_intbig_gist.c
- for (i = 0; i < len; i++)
- {
- if (unionkey(base, GETENTRY(entryvec, i)))
- {
- flag = ALLISTRUE;
- break;
- }
- }
- len = CALCGTSIZE(flag);
- result = (GISTTYPE *) palloc(len);
- SET_VARSIZE(result, len);
- result->flag = flag;
- if (!ISALLTRUE(result))
- memcpy((void *) GETSIGN(result), (void *) base, sizeof(BITVEC));
- *size = len;
- PG_RETURN_POINTER(result);
- }
- Datum
- =====================================================================
- Found a 24 line (102 tokens) duplication in the following files:
- Starting at line 477 of /home/shackle/pggit/postgresql/contrib/ltree/_ltree_gist.c
- Starting at line 476 of /home/shackle/pggit/postgresql/contrib/ltree/ltree_gist.c
- );
- }
- static bool
- gist_qe(ltree_gist *key, lquery *query)
- {
- lquery_level *curq = LQUERY_FIRST(query);
- BITVECP sign = LTG_SIGN(key);
- int qlen = query->numlevel;
- if (LTG_ISALLTRUE(key))
- return true;
- while (qlen > 0)
- {
- if (curq->numvar && LQL_CANLOOKSIGN(curq))
- {
- bool isexist = false;
- int vlen = curq->numvar;
- lquery_variant *curv = LQL_FIRST(curq);
- while (vlen > 0)
- {
- if (GETBIT(sign, AHASHVAL(curv->val)))
- =====================================================================
- Found a 29 line (102 tokens) duplication in the following files:
- Starting at line 143 of /home/shackle/pggit/postgresql/src/bin/scripts/vacuumdb.c
- Starting at line 70 of /home/shackle/pggit/postgresql/src/bin/scripts/clusterdb.c
- while ((c = getopt_long(argc, argv, "h:p:U:wWeqd:zZFat:fvj:", long_options, &optindex)) != -1)
- {
- switch (c)
- {
- case 'h':
- host = pg_strdup(optarg);
- break;
- case 'p':
- port = pg_strdup(optarg);
- break;
- case 'U':
- username = pg_strdup(optarg);
- break;
- case 'w':
- prompt_password = TRI_NO;
- break;
- case 'W':
- prompt_password = TRI_YES;
- break;
- case 'e':
- echo = true;
- break;
- case 'q':
- quiet = true;
- break;
- case 'd':
- dbname = pg_strdup(optarg);
- break;
- case 'z':
- =====================================================================
- Found a 36 line (102 tokens) duplication in the following files:
- Starting at line 4171 of /home/shackle/pggit/postgresql/src/pl/plpgsql/src/pl_exec.c
- Starting at line 4361 of /home/shackle/pggit/postgresql/src/pl/plpgsql/src/pl_exec.c
- expr->query, SPI_result_code_string(rc));
- break;
- }
- /* All variants should save result info for GET DIAGNOSTICS */
- estate->eval_processed = SPI_processed;
- /* Process INTO if present */
- if (stmt->into)
- {
- SPITupleTable *tuptab = SPI_tuptable;
- uint64 n = SPI_processed;
- PLpgSQL_variable *target;
- /* If the statement did not return a tuple table, complain */
- if (tuptab == NULL)
- ereport(ERROR,
- (errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("INTO used with a command that cannot return data")));
- /* Fetch target's datum entry */
- target = (PLpgSQL_variable *) estate->datums[stmt->target->dno];
- /*
- * If SELECT ... INTO specified STRICT, and the query didn't find
- * exactly one row, throw an error. If STRICT was not specified, then
- * allow the query to find any number of rows.
- */
- if (n == 0)
- {
- if (stmt->strict)
- {
- char *errdetail;
- if (estate->func->print_strict_params)
- errdetail = format_expr_params(estate, expr);
- =====================================================================
- Found a 31 line (102 tokens) duplication in the following files:
- Starting at line 2294 of /home/shackle/pggit/postgresql/src/pl/plperl/plperl.c
- Starting at line 2357 of /home/shackle/pggit/postgresql/src/pl/plperl/plperl.c
- PUSHs(sv_2mortal(cstr2sv(tg_trigger->tgargs[i])));
- PUTBACK;
- /* Do NOT use G_KEEPERR here */
- count = perl_call_sv(desc->reference, G_SCALAR | G_EVAL);
- SPAGAIN;
- if (count != 1)
- {
- PUTBACK;
- FREETMPS;
- LEAVE;
- ereport(ERROR,
- (errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
- errmsg("didn't get a return item from trigger function")));
- }
- if (SvTRUE(ERRSV))
- {
- (void) POPs;
- PUTBACK;
- FREETMPS;
- LEAVE;
- /* XXX need to find a way to determine a better errcode here */
- ereport(ERROR,
- (errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
- errmsg("%s", strip_trailing_ws(sv2cstr(ERRSV)))));
- }
- retval = newSVsv(POPs);
- =====================================================================
- Found a 36 line (102 tokens) duplication in the following files:
- Starting at line 3410 of /home/shackle/pggit/postgresql/src/pl/plperl/plperl.c
- Starting at line 3893 of /home/shackle/pggit/postgresql/src/pl/plperl/plperl.c
- if (portal == NULL)
- elog(ERROR, "SPI_cursor_open() failed:%s",
- SPI_result_code_string(SPI_result));
- cursor = cstr2sv(portal->name);
- PinPortal(portal);
- /* Commit the inner transaction, return to outer xact context */
- ReleaseCurrentSubTransaction();
- MemoryContextSwitchTo(oldcontext);
- CurrentResourceOwner = oldowner;
- }
- PG_CATCH();
- {
- ErrorData *edata;
- /* Save error info */
- MemoryContextSwitchTo(oldcontext);
- edata = CopyErrorData();
- FlushErrorState();
- /* Abort the inner transaction */
- RollbackAndReleaseCurrentSubTransaction();
- MemoryContextSwitchTo(oldcontext);
- CurrentResourceOwner = oldowner;
- /* Punt the error to Perl */
- croak_cstr(edata->message);
- /* Can't get here, but keep compiler quiet */
- return NULL;
- }
- PG_END_TRY();
- return cursor;
- }
- =====================================================================
- Found a 4 line (102 tokens) duplication in the following files:
- Starting at line 30 of /home/shackle/pggit/postgresql/src/common/base64.c
- Starting at line 3562 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
- Starting at line 888 of /home/shackle/pggit/postgresql/src/backend/utils/adt/formatting.c
- Starting at line 114 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 206 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 40 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
- static const int8 b64lookup[128] = {
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
- =====================================================================
- Found a 3 line (102 tokens) duplication in the following files:
- Starting at line 31 of /home/shackle/pggit/postgresql/src/common/base64.c
- Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
- Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 207 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
- =====================================================================
- Found a 3 line (102 tokens) duplication in the following files:
- Starting at line 31 of /home/shackle/pggit/postgresql/src/common/base64.c
- Starting at line 3563 of /home/shackle/pggit/postgresql/src/interfaces/libpq/fe-exec.c
- Starting at line 115 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 207 of /home/shackle/pggit/postgresql/src/backend/utils/adt/encode.c
- Starting at line 41 of /home/shackle/pggit/postgresql/src/backend/utils/adt/mac8.c
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
- =====================================================================
- Found a 26 line (102 tokens) duplication in the following files:
- Starting at line 599 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/numeric.c
- Starting at line 687 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/pgtypeslib/numeric.c
- carry = 0;
- }
- }
- while (res_ndigits > 0 && *res_digits == 0)
- {
- res_digits++;
- res_weight--;
- res_ndigits--;
- }
- while (res_ndigits > 0 && res_digits[res_ndigits - 1] == 0)
- res_ndigits--;
- if (res_ndigits == 0)
- res_weight = 0;
- digitbuf_free(result->buf);
- result->ndigits = res_ndigits;
- result->buf = res_buf;
- result->digits = res_digits;
- result->weight = res_weight;
- result->rscale = res_rscale;
- result->dscale = res_dscale;
- return 0;
- }
- =====================================================================
- Found a 5 line (102 tokens) duplication in the following files:
- Starting at line 98 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
- Starting at line 103 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- =====================================================================
- Found a 14 line (102 tokens) duplication in the following files:
- Starting at line 893 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
- Starting at line 1213 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
- Starting at line 1520 of /home/shackle/pggit/postgresql/src/backend/utils/fmgr/fmgr.c
- InitFunctionCallInfoData(fcinfo, NULL, 5, collation, NULL, NULL);
- fcinfo.arg[0] = arg1;
- fcinfo.arg[1] = arg2;
- fcinfo.arg[2] = arg3;
- fcinfo.arg[3] = arg4;
- fcinfo.arg[4] = arg5;
- fcinfo.argnull[0] = false;
- fcinfo.argnull[1] = false;
- fcinfo.argnull[2] = false;
- fcinfo.argnull[3] = false;
- fcinfo.argnull[4] = false;
- result = (*func) (&fcinfo);
- =====================================================================
- Found a 23 line (102 tokens) duplication in the following files:
- Starting at line 171 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c
- Starting at line 598 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c
- c2 = sjis[1];
- k = (c1 << 8) + c2;
- if (k >= 0xed40 && k < 0xf040)
- {
- /* NEC selection IBM kanji */
- for (i = 0;; i++)
- {
- k2 = ibmkanji[i].nec;
- if (k2 == 0xffff)
- break;
- if (k2 == k)
- {
- k = ibmkanji[i].sjis;
- c1 = (k >> 8) & 0xff;
- c2 = k & 0xff;
- }
- }
- }
- if (k < 0xeb3f)
- {
- /* JIS X0208 */
- *p++ = LC_JISX0208;
- =====================================================================
- Found a 61 line (102 tokens) duplication in the following files:
- Starting at line 6674 of /home/shackle/pggit/postgresql/src/backend/utils/adt/numeric.c
- Starting at line 6795 of /home/shackle/pggit/postgresql/src/backend/utils/adt/numeric.c
- if (var2->sign == NUMERIC_POS)
- {
- /* ----------
- * var1 is negative, var2 is positive
- * Must compare absolute values
- * ----------
- */
- switch (cmp_abs(var1, var2))
- {
- case 0:
- /* ----------
- * ABS(var1) == ABS(var2)
- * result = ZERO
- * ----------
- */
- zero_var(result);
- result->dscale = Max(var1->dscale, var2->dscale);
- break;
- case 1:
- /* ----------
- * ABS(var1) > ABS(var2)
- * result = -(ABS(var1) - ABS(var2))
- * ----------
- */
- sub_abs(var1, var2, result);
- result->sign = NUMERIC_NEG;
- break;
- case -1:
- /* ----------
- * ABS(var1) < ABS(var2)
- * result = +(ABS(var2) - ABS(var1))
- * ----------
- */
- sub_abs(var2, var1, result);
- result->sign = NUMERIC_POS;
- break;
- }
- }
- else
- {
- /* ----------
- * Both are negative
- * result = -(ABS(var1) + ABS(var2))
- * ----------
- */
- add_abs(var1, var2, result);
- result->sign = NUMERIC_NEG;
- }
- }
- }
- /*
- * sub_var() -
- *
- * Full version of sub functionality on variable level (handling signs).
- * result might point to one of the operands too without danger.
- */
- static void
- =====================================================================
- Found a 24 line (102 tokens) duplication in the following files:
- Starting at line 323 of /home/shackle/pggit/postgresql/src/backend/utils/adt/varbit.c
- Starting at line 638 of /home/shackle/pggit/postgresql/src/backend/utils/adt/varbit.c
- bitlen, atttypmod)));
- len = VARBITTOTALLEN(bitlen);
- result = (VarBit *) palloc(len);
- SET_VARSIZE(result, len);
- VARBITLEN(result) = bitlen;
- pq_copymsgbytes(buf, (char *) VARBITS(result), VARBITBYTES(result));
- /* Make sure last byte is zero-padded if needed */
- ipad = VARBITPAD(result);
- if (ipad > 0)
- {
- mask = BITMASK << ipad;
- *(VARBITS(result) + VARBITBYTES(result) - 1) &= mask;
- }
- PG_RETURN_VARBIT_P(result);
- }
- /*
- * bit_send - converts bit to binary format
- */
- Datum
- =====================================================================
- Found a 20 line (102 tokens) duplication in the following files:
- Starting at line 1394 of /home/shackle/pggit/postgresql/src/backend/utils/adt/varbit.c
- Starting at line 1459 of /home/shackle/pggit/postgresql/src/backend/utils/adt/varbit.c
- PG_RETURN_DATUM(DirectFunctionCall2(bitshiftright,
- VarBitPGetDatum(arg),
- Int32GetDatum(-shft)));
- }
- result = (VarBit *) palloc(VARSIZE(arg));
- SET_VARSIZE(result, VARSIZE(arg));
- VARBITLEN(result) = VARBITLEN(arg);
- r = VARBITS(result);
- /* If we shifted all the bits out, return an all-zero string */
- if (shft >= VARBITLEN(arg))
- {
- MemSet(r, 0, VARBITBYTES(arg));
- PG_RETURN_VARBIT_P(result);
- }
- byte_shift = shft / BITS_PER_BYTE;
- ishift = shft % BITS_PER_BYTE;
- p = VARBITS(arg) + byte_shift;
- =====================================================================
- Found a 20 line (101 tokens) duplication in the following files:
- Starting at line 113 of /home/shackle/pggit/postgresql/src/port/qsort.c
- Starting at line 113 of /home/shackle/pggit/postgresql/src/port/qsort_arg.c
- pg_qsort(void *a, size_t n, size_t es, int (*cmp) (const void *, const void *))
- {
- char *pa,
- *pb,
- *pc,
- *pd,
- *pl,
- *pm,
- *pn;
- size_t d1,
- d2;
- int r,
- swaptype,
- presorted;
- loop:SWAPINIT(a, es);
- if (n < 7)
- {
- for (pm = (char *) a + es; pm < (char *) a + n * es; pm += es)
- for (pl = pm; pl > (char *) a && cmp(pl - es, pl) > 0;
- =====================================================================
- Found a 18 line (101 tokens) duplication in the following files:
- Starting at line 140 of /home/shackle/pggit/postgresql/src/port/qsort.c
- Starting at line 140 of /home/shackle/pggit/postgresql/src/port/qsort_arg.c
- if (cmp(pm - es, pm) > 0)
- {
- presorted = 0;
- break;
- }
- }
- if (presorted)
- return;
- pm = (char *) a + (n / 2) * es;
- if (n > 7)
- {
- pl = (char *) a;
- pn = (char *) a + (n - 1) * es;
- if (n > 40)
- {
- size_t d = (n / 8) * es;
- pl = med3(pl, pl + d, pl + 2 * d, cmp);
- =====================================================================
- Found a 21 line (101 tokens) duplication in the following files:
- Starting at line 427 of /home/shackle/pggit/postgresql/src/bin/pg_basebackup/streamutil.c
- Starting at line 489 of /home/shackle/pggit/postgresql/src/bin/pg_basebackup/receivelog.c
- res = PQexec(conn, "IDENTIFY_SYSTEM");
- if (PQresultStatus(res) != PGRES_TUPLES_OK)
- {
- fprintf(stderr, _("%s: could not send replication command \"%s\": %s"),
- progname, "IDENTIFY_SYSTEM", PQerrorMessage(conn));
- PQclear(res);
- return false;
- }
- if (PQntuples(res) != 1 || PQnfields(res) < 3)
- {
- fprintf(stderr,
- _("%s: could not identify system: got %d rows and %d fields, expected %d rows and %d or more fields\n"),
- progname, PQntuples(res), PQnfields(res), 1, 3);
- PQclear(res);
- return false;
- }
- /* Get system identifier */
- if (sysid != NULL)
- =====================================================================
- Found a 31 line (101 tokens) duplication in the following files:
- Starting at line 296 of /home/shackle/pggit/postgresql/src/include/catalog/pg_type.h
- Starting at line 191 of /home/shackle/pggit/postgresql/src/backend/catalog/pg_type.c
- extern ObjectAddress TypeCreate(Oid newTypeOid,
- const char *typeName,
- Oid typeNamespace,
- Oid relationOid,
- char relationKind,
- Oid ownerId,
- int16 internalSize,
- char typeType,
- char typeCategory,
- bool typePreferred,
- char typDelim,
- Oid inputProcedure,
- Oid outputProcedure,
- Oid receiveProcedure,
- Oid sendProcedure,
- Oid typmodinProcedure,
- Oid typmodoutProcedure,
- Oid analyzeProcedure,
- Oid elementType,
- bool isImplicitArray,
- Oid arrayType,
- Oid baseType,
- const char *defaultTypeValue,
- char *defaultTypeBin,
- bool passedByValue,
- char alignment,
- char storage,
- int32 typeMod,
- int32 typNDims,
- bool typeNotNull,
- Oid typeCollation);
- =====================================================================
- Found a 20 line (101 tokens) duplication in the following files:
- Starting at line 113 of /home/shackle/pggit/postgresql/src/pl/plpython/plpy_resultobject.c
- Starting at line 139 of /home/shackle/pggit/postgresql/src/pl/plpython/plpy_resultobject.c
- Starting at line 165 of /home/shackle/pggit/postgresql/src/pl/plpython/plpy_resultobject.c
- PLy_result_colnames(PyObject *self, PyObject *unused)
- {
- PLyResultObject *ob = (PLyResultObject *) self;
- PyObject *list;
- int i;
- if (!ob->tupdesc)
- {
- PLy_exception_set(PLy_exc_error, "command did not produce a result set");
- return NULL;
- }
- list = PyList_New(ob->tupdesc->natts);
- if (!list)
- return NULL;
- for (i = 0; i < ob->tupdesc->natts; i++)
- {
- Form_pg_attribute attr = TupleDescAttr(ob->tupdesc, i);
- PyList_SET_ITEM(list, i, PyString_FromString(NameStr(attr->attname)));
- =====================================================================
- Found a 11 line (101 tokens) duplication in the following files:
- Starting at line 193 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-oldexec.c
- Starting at line 208 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-execute.c
- { ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "declare CUR3 cursor for $1",
- ECPGt_char_variable,(ECPGprepared_statement(NULL, "f", __LINE__)),(long)1,(long)1,(1)*sizeof(char),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_const,"1",(long)1,(long)1,strlen("1"),
- ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
- #line 72 "oldexec.pgc"
- if (sqlca.sqlcode < 0) sqlprint();}
- #line 72 "oldexec.pgc"
- { ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "fetch in CUR3", ECPGt_EOIT,
- =====================================================================
- Found a 17 line (101 tokens) duplication in the following files:
- Starting at line 5412 of /home/shackle/pggit/postgresql/src/backend/optimizer/plan/createplan.c
- Starting at line 6387 of /home/shackle/pggit/postgresql/src/backend/optimizer/plan/createplan.c
- ListCell *slitem;
- dupColIdx = (AttrNumber *) palloc(sizeof(AttrNumber) * numCols);
- dupOperators = (Oid *) palloc(sizeof(Oid) * numCols);
- foreach(slitem, distinctList)
- {
- SortGroupClause *sortcl = (SortGroupClause *) lfirst(slitem);
- TargetEntry *tle = get_sortgroupclause_tle(sortcl,
- plan->targetlist);
- dupColIdx[keyno] = tle->resno;
- dupOperators[keyno] = sortcl->eqop;
- Assert(OidIsValid(dupOperators[keyno]));
- keyno++;
- }
- node->dupColIdx = dupColIdx;
- =====================================================================
- Found a 24 line (101 tokens) duplication in the following files:
- Starting at line 678 of /home/shackle/pggit/postgresql/src/backend/storage/lmgr/deadlock.c
- Starting at line 751 of /home/shackle/pggit/postgresql/src/backend/storage/lmgr/deadlock.c
- if ((LOCKBIT_ON(proc->waitLockMode) & conflictMask) != 0)
- {
- /* This proc soft-blocks checkProc */
- if (FindLockCycleRecurse(proc, depth + 1,
- softEdges, nSoftEdges))
- {
- /* fill deadlockDetails[] */
- DEADLOCK_INFO *info = &deadlockDetails[depth];
- info->locktag = lock->tag;
- info->lockmode = checkProc->waitLockMode;
- info->pid = checkProc->pid;
- /*
- * Add this edge to the list of soft edges in the cycle
- */
- Assert(*nSoftEdges < MaxBackends);
- softEdges[*nSoftEdges].waiter = checkProcLeader;
- softEdges[*nSoftEdges].blocker = leader;
- softEdges[*nSoftEdges].lock = lock;
- (*nSoftEdges)++;
- return true;
- }
- }
- =====================================================================
- Found a 22 line (101 tokens) duplication in the following files:
- Starting at line 1220 of /home/shackle/pggit/postgresql/src/backend/catalog/pg_constraint.c
- Starting at line 1281 of /home/shackle/pggit/postgresql/src/backend/catalog/pg_constraint.c
- Oid conOid = InvalidOid;
- pg_constraint = heap_open(ConstraintRelationId, AccessShareLock);
- ScanKeyInit(&skey[0],
- Anum_pg_constraint_conrelid,
- BTEqualStrategyNumber, F_OIDEQ,
- ObjectIdGetDatum(relid));
- ScanKeyInit(&skey[1],
- Anum_pg_constraint_contypid,
- BTEqualStrategyNumber, F_OIDEQ,
- ObjectIdGetDatum(InvalidOid));
- ScanKeyInit(&skey[2],
- Anum_pg_constraint_conname,
- BTEqualStrategyNumber, F_NAMEEQ,
- CStringGetDatum(conname));
- scan = systable_beginscan(pg_constraint, ConstraintRelidTypidNameIndexId, true,
- NULL, 3, skey);
- /* There can be at most one matching row */
- if (HeapTupleIsValid(tuple = systable_getnext(scan)))
- =====================================================================
- Found a 24 line (101 tokens) duplication in the following files:
- Starting at line 192 of /home/shackle/pggit/postgresql/src/backend/catalog/pg_depend.c
- Starting at line 242 of /home/shackle/pggit/postgresql/src/backend/catalog/pg_depend.c
- bool skipExtensionDeps)
- {
- long count = 0;
- Relation depRel;
- ScanKeyData key[2];
- SysScanDesc scan;
- HeapTuple tup;
- depRel = heap_open(DependRelationId, RowExclusiveLock);
- ScanKeyInit(&key[0],
- Anum_pg_depend_classid,
- BTEqualStrategyNumber, F_OIDEQ,
- ObjectIdGetDatum(classId));
- ScanKeyInit(&key[1],
- Anum_pg_depend_objid,
- BTEqualStrategyNumber, F_OIDEQ,
- ObjectIdGetDatum(objectId));
- scan = systable_beginscan(depRel, DependDependerIndexId, true,
- NULL, 2, key);
- while (HeapTupleIsValid(tup = systable_getnext(scan)))
- {
- =====================================================================
- Found a 22 line (101 tokens) duplication in the following files:
- Starting at line 199 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/euc_tw_and_big5.c
- Starting at line 307 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/euc_tw_and_big5.c
- int c1;
- int l;
- while (len > 0)
- {
- c1 = *mic;
- if (!IS_HIGHBIT_SET(c1))
- {
- /* ASCII */
- if (c1 == 0)
- report_invalid_encoding(PG_MULE_INTERNAL,
- (const char *) mic, len);
- *p++ = c1;
- mic++;
- len--;
- continue;
- }
- l = pg_encoding_verifymb(PG_MULE_INTERNAL, (const char *) mic, len);
- if (l < 0)
- report_invalid_encoding(PG_MULE_INTERNAL,
- (const char *) mic, len);
- if (c1 == LC_CNS11643_1)
- =====================================================================
- Found a 9 line (101 tokens) duplication in the following files:
- Starting at line 1737 of /home/shackle/pggit/postgresql/src/backend/utils/mb/wchar.c
- Starting at line 1757 of /home/shackle/pggit/postgresql/src/backend/utils/mb/wchar.c
- {pg_mule2wchar_with_len, pg_wchar2mule_with_len, pg_mule_mblen, pg_mule_dsplen, pg_mule_verifier, 4}, /* PG_MULE_INTERNAL */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN1 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN2 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN3 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN4 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN5 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN6 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN7 */
- {pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN8 */
- =====================================================================
- Found a 38 line (101 tokens) duplication in the following files:
- Starting at line 1160 of /home/shackle/pggit/postgresql/src/backend/utils/adt/jsonfuncs.c
- Starting at line 1303 of /home/shackle/pggit/postgresql/src/backend/utils/adt/jsonfuncs.c
- strcmp(fname, _state->path_names[lex_level - 1]) == 0)
- {
- if (lex_level < _state->npath)
- {
- /* done with this field so reset pathok */
- _state->pathok[lex_level] = false;
- }
- else
- {
- /* end of path, so we want this value */
- get_last = true;
- }
- }
- /* for as_text scalar case, our work is already done */
- if (get_last && _state->result_start != NULL)
- {
- /*
- * make a text object from the string from the previously noted json
- * start up to the end of the previous token (the lexer is by now
- * ahead of us on whatever came after what we're interested in).
- */
- if (isnull && _state->normalize_results)
- _state->tresult = (text *) NULL;
- else
- {
- char *start = _state->result_start;
- int len = _state->lex->prev_token_terminator - start;
- _state->tresult = cstring_to_text_with_len(start, len);
- }
- /* this should be unnecessary but let's do it for cleanliness: */
- _state->result_start = NULL;
- }
- }
- static void
- =====================================================================
- Found a 22 line (101 tokens) duplication in the following files:
- Starting at line 3597 of /home/shackle/pggit/postgresql/src/backend/utils/adt/numeric.c
- Starting at line 3685 of /home/shackle/pggit/postgresql/src/backend/utils/adt/numeric.c
- numeric_combine(PG_FUNCTION_ARGS)
- {
- NumericAggState *state1;
- NumericAggState *state2;
- MemoryContext agg_context;
- MemoryContext old_context;
- if (!AggCheckCallContext(fcinfo, &agg_context))
- elog(ERROR, "aggregate function called in non-aggregate context");
- state1 = PG_ARGISNULL(0) ? NULL : (NumericAggState *) PG_GETARG_POINTER(0);
- state2 = PG_ARGISNULL(1) ? NULL : (NumericAggState *) PG_GETARG_POINTER(1);
- if (state2 == NULL)
- PG_RETURN_POINTER(state1);
- /* manually copy all fields from state2 to state1 */
- if (state1 == NULL)
- {
- old_context = MemoryContextSwitchTo(agg_context);
- state1 = makeNumericAggStateCurrentContext(true);
- =====================================================================
- Found a 26 line (101 tokens) duplication in the following files:
- Starting at line 5222 of /home/shackle/pggit/postgresql/src/backend/utils/adt/varlena.c
- Starting at line 5279 of /home/shackle/pggit/postgresql/src/backend/utils/adt/varlena.c
- arg = widthpos;
- if (arg >= nargs)
- ereport(ERROR,
- (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("too few arguments for format()")));
- /* Get the value and type of the selected argument */
- if (!funcvariadic)
- {
- value = PG_GETARG_DATUM(arg);
- isNull = PG_ARGISNULL(arg);
- typid = get_fn_expr_argtype(fcinfo->flinfo, arg);
- }
- else
- {
- value = elements[arg - 1];
- isNull = nulls[arg - 1];
- typid = element_type;
- }
- if (!OidIsValid(typid))
- elog(ERROR, "could not determine data type of format() input");
- arg++;
- /* We can treat NULL width the same as zero */
- if (isNull)
- =====================================================================
- Found a 25 line (101 tokens) duplication in the following files:
- Starting at line 1375 of /home/shackle/pggit/postgresql/src/backend/commands/opclasscmds.c
- Starting at line 1487 of /home/shackle/pggit/postgresql/src/backend/commands/opclasscmds.c
- referenced.objectId = op->object;
- referenced.objectSubId = 0;
- if (OidIsValid(opclassoid))
- {
- /* if contained in an opclass, use a NORMAL dep on operator */
- recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
- /* ... and an INTERNAL dep on the opclass */
- referenced.classId = OperatorClassRelationId;
- referenced.objectId = opclassoid;
- referenced.objectSubId = 0;
- recordDependencyOn(&myself, &referenced, DEPENDENCY_INTERNAL);
- }
- else
- {
- /* if "loose" in the opfamily, use a AUTO dep on operator */
- recordDependencyOn(&myself, &referenced, DEPENDENCY_AUTO);
- /* ... and an AUTO dep on the opfamily */
- referenced.classId = OperatorFamilyRelationId;
- referenced.objectId = opfamilyoid;
- referenced.objectSubId = 0;
- recordDependencyOn(&myself, &referenced, DEPENDENCY_AUTO);
- }
- =====================================================================
- Found a 18 line (101 tokens) duplication in the following files:
- Starting at line 6189 of /home/shackle/pggit/postgresql/src/backend/commands/tablecmds.c
- Starting at line 6248 of /home/shackle/pggit/postgresql/src/backend/commands/tablecmds.c
- attrelation = heap_open(AttributeRelationId, RowExclusiveLock);
- tuple = SearchSysCacheCopyAttName(RelationGetRelid(rel), colName);
- if (!HeapTupleIsValid(tuple))
- ereport(ERROR,
- (errcode(ERRCODE_UNDEFINED_COLUMN),
- errmsg("column \"%s\" of relation \"%s\" does not exist",
- colName, RelationGetRelationName(rel))));
- attTup = (Form_pg_attribute) GETSTRUCT(tuple);
- attnum = attTup->attnum;
- if (attnum <= 0)
- ereport(ERROR,
- (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("cannot alter system column \"%s\"",
- colName)));
- if (!attTup->attidentity)
- =====================================================================
- Found a 27 line (100 tokens) duplication in the following files:
- Starting at line 1837 of /home/shackle/pggit/postgresql/contrib/postgres_fdw/postgres_fdw.c
- Starting at line 1913 of /home/shackle/pggit/postgresql/contrib/postgres_fdw/postgres_fdw.c
- postgresExecForeignUpdate(EState *estate,
- ResultRelInfo *resultRelInfo,
- TupleTableSlot *slot,
- TupleTableSlot *planSlot)
- {
- PgFdwModifyState *fmstate = (PgFdwModifyState *) resultRelInfo->ri_FdwState;
- Datum datum;
- bool isNull;
- const char **p_values;
- PGresult *res;
- int n_rows;
- /* Set up the prepared statement on the remote server, if we didn't yet */
- if (!fmstate->p_name)
- prepare_foreign_modify(fmstate);
- /* Get the ctid that was passed up as a resjunk column */
- datum = ExecGetJunkAttribute(planSlot,
- fmstate->ctidAttno,
- &isNull);
- /* shouldn't ever get a null result... */
- if (isNull)
- elog(ERROR, "ctid is NULL");
- /* Convert parameters needed by prepared statement to text form */
- p_values = convert_prep_stmt_params(fmstate,
- (ItemPointer) DatumGetPointer(datum),
- =====================================================================
- Found a 29 line (100 tokens) duplication in the following files:
- Starting at line 32 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/ecpglib/misc.c
- Starting at line 63 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/ecpglib/misc.c
- Starting at line 21 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/compatlib/informix.c
- static struct sqlca_t sqlca_init =
- {
- {
- 'S', 'Q', 'L', 'C', 'A', ' ', ' ', ' '
- },
- sizeof(struct sqlca_t),
- 0,
- {
- 0,
- {
- 0
- }
- },
- {
- 'N', 'O', 'T', ' ', 'S', 'E', 'T', ' '
- },
- {
- 0, 0, 0, 0, 0, 0
- },
- {
- 0, 0, 0, 0, 0, 0, 0, 0
- },
- {
- '0', '0', '0', '0', '0'
- }
- };
- #ifdef ENABLE_THREAD_SAFETY
- static pthread_key_t sqlca_key;
- =====================================================================
- Found a 28 line (100 tokens) duplication in the following files:
- Starting at line 378 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-sqlda.c
- Starting at line 441 of /home/shackle/pggit/postgresql/src/interfaces/ecpg/test/expected/sql-sqlda.c
- { ECPGdeallocate(__LINE__, 0, NULL, "st_id2");
- #line 172 "sqlda.pgc"
- if (sqlca.sqlcode < 0) exit (1);}
- #line 172 "sqlda.pgc"
- /* SQLDA test for getting one record using an input descriptor */
- /*
- * Input sqlda has to be built manually
- * sqlda_t contains 1 sqlvar_t structure already.
- */
- inp_sqlda = (sqlda_t *)malloc(sizeof(sqlda_t));
- memset(inp_sqlda, 0, sizeof(sqlda_t));
- inp_sqlda->sqln = 1;
- inp_sqlda->sqlvar[0].sqltype = ECPGt_int;
- inp_sqlda->sqlvar[0].sqldata = (char *)&id;
- printf("EXECUTE RECORD 4\n");
- id = 4;
- outp_sqlda = NULL;
- strcpy(msg, "prepare");
- { ECPGprepare(__LINE__, NULL, 0, "st_id3", stmt2);
- =====================================================================
- Found a 23 line (100 tokens) duplication in the following files:
- Starting at line 6035 of /home/shackle/pggit/postgresql/src/backend/optimizer/plan/planner.c
- Starting at line 6152 of /home/shackle/pggit/postgresql/src/backend/optimizer/plan/planner.c
- return true; /* use sort */
- /* Set up mostly-dummy planner state */
- query = makeNode(Query);
- query->commandType = CMD_SELECT;
- glob = makeNode(PlannerGlobal);
- root = makeNode(PlannerInfo);
- root->parse = query;
- root->glob = glob;
- root->query_level = 1;
- root->planner_cxt = CurrentMemoryContext;
- root->wt_param_id = -1;
- /* Build a minimal RTE for the rel */
- rte = makeNode(RangeTblEntry);
- rte->rtekind = RTE_RELATION;
- rte->relid = tableOid;
- rte->relkind = RELKIND_RELATION; /* Don't be too picky. */
- rte->rellockmode = AccessShareLock;
- rte->lateral = false;
- rte->inh = false;
- =====================================================================
- Found a 28 line (100 tokens) duplication in the following files:
- Starting at line 1116 of /home/shackle/pggit/postgresql/src/backend/regex/regexec.c
- Starting at line 1328 of /home/shackle/pggit/postgresql/src/backend/regex/regexec.c
- endpts[k] = longest(v, d, endpts[k - 1], limit, (int *) NULL);
- if (ISERR())
- {
- FREE(endpts);
- return v->err;
- }
- if (endpts[k] == NULL)
- {
- /* no match possible, so see if we can shorten previous one */
- k--;
- goto backtrack;
- }
- MDEBUG(("%d: working endpoint %d: %ld\n",
- t->id, k, LOFF(endpts[k])));
- /* k'th sub-match can no longer be considered verified */
- if (nverified >= k)
- nverified = k - 1;
- if (endpts[k] != end)
- {
- /* haven't reached end yet, try another iteration if allowed */
- if (k >= max_matches)
- {
- /* must try to shorten some previous match */
- k--;
- goto backtrack;
- }
- =====================================================================
- Found a 5 line (100 tokens) duplication in the following files:
- Starting at line 98 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
- Starting at line 103 of /home/shackle/pggit/postgresql/src/backend/nodes/bitmapset.c
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- =====================================================================
- Found a 23 line (100 tokens) duplication in the following files:
- Starting at line 1049 of /home/shackle/pggit/postgresql/src/backend/utils/mmgr/mcxt.c
- Starting at line 1119 of /home/shackle/pggit/postgresql/src/backend/utils/mmgr/mcxt.c
- if (!AllocSizeIsValid(size))
- elog(ERROR, "invalid memory alloc request size %zu", size);
- AssertNotInCriticalSection(context);
- /* isReset must be false already */
- Assert(!context->isReset);
- ret = context->methods->realloc(context, pointer, size);
- if (unlikely(ret == NULL))
- {
- MemoryContextStats(TopMemoryContext);
- ereport(ERROR,
- (errcode(ERRCODE_OUT_OF_MEMORY),
- errmsg("out of memory"),
- errdetail("Failed on request of size %zu in memory context \"%s\".",
- size, context->name)));
- }
- VALGRIND_MEMPOOL_CHANGE(context, pointer, ret, size);
- return ret;
- }
- =====================================================================
- Found a 21 line (100 tokens) duplication in the following files:
- Starting at line 278 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c
- Starting at line 418 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c
- l;
- while (len > 0)
- {
- c1 = *mic;
- if (!IS_HIGHBIT_SET(c1))
- {
- /* ASCII */
- if (c1 == 0)
- report_invalid_encoding(PG_MULE_INTERNAL,
- (const char *) mic, len);
- *p++ = c1;
- mic++;
- len--;
- continue;
- }
- l = pg_encoding_verifymb(PG_MULE_INTERNAL, (const char *) mic, len);
- if (l < 0)
- report_invalid_encoding(PG_MULE_INTERNAL,
- (const char *) mic, len);
- if (c1 == LC_JISX0201K)
- =====================================================================
- Found a 22 line (100 tokens) duplication in the following files:
- Starting at line 417 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c
- Starting at line 307 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/euc_tw_and_big5.c
- Starting at line 108 of /home/shackle/pggit/postgresql/src/backend/utils/mb/conversion_procs/euc_kr_and_mic/euc_kr_and_mic.c
- int c1;
- int l;
- while (len > 0)
- {
- c1 = *mic;
- if (!IS_HIGHBIT_SET(c1))
- {
- /* ASCII */
- if (c1 == 0)
- report_invalid_encoding(PG_MULE_INTERNAL,
- (const char *) mic, len);
- *p++ = c1;
- mic++;
- len--;
- continue;
- }
- l = pg_encoding_verifymb(PG_MULE_INTERNAL, (const char *) mic, len);
- if (l < 0)
- report_invalid_encoding(PG_MULE_INTERNAL,
- (const char *) mic, len);
- if (c1 == LC_JISX0201K)
- =====================================================================
- Found a 18 line (100 tokens) duplication in the following files:
- Starting at line 1997 of /home/shackle/pggit/postgresql/src/backend/utils/mb/wchar.c
- Starting at line 2030 of /home/shackle/pggit/postgresql/src/backend/utils/mb/wchar.c
- int l = pg_encoding_mblen(encoding, mbstr);
- char buf[8 * 5 + 1];
- char *p = buf;
- int j,
- jlimit;
- jlimit = Min(l, len);
- jlimit = Min(jlimit, 8); /* prevent buffer overrun */
- for (j = 0; j < jlimit; j++)
- {
- p += sprintf(p, "0x%02x", (unsigned char) mbstr[j]);
- if (j < jlimit - 1)
- p += sprintf(p, " ");
- }
- ereport(ERROR,
- (errcode(ERRCODE_CHARACTER_NOT_IN_REPERTOIRE),
- =====================================================================
- Found a 34 line (100 tokens) duplication in the following files:
- Starting at line 6267 of /home/shackle/pggit/postgresql/src/backend/utils/adt/numeric.c
- Starting at line 6391 of /home/shackle/pggit/postgresql/src/backend/utils/adt/numeric.c
- int64 val;
- bool neg;
- NumericVar rounded;
- /* Round to nearest integer */
- init_var(&rounded);
- set_var_from_var(var, &rounded);
- round_var(&rounded, 0);
- /* Check for zero input */
- strip_var(&rounded);
- ndigits = rounded.ndigits;
- if (ndigits == 0)
- {
- *result = 0;
- free_var(&rounded);
- return true;
- }
- /*
- * For input like 10000000000, we must treat stripped digits as real. So
- * the loop assumes there are weight+1 digits before the decimal point.
- */
- weight = rounded.weight;
- Assert(weight >= 0 && ndigits <= weight + 1);
- /*
- * Construct the result. To avoid issues with converting a value
- * corresponding to INT64_MIN (which can't be represented as a positive 64
- * bit two's complement integer), accumulate value as a negative number.
- */
- digits = rounded.digits;
- neg = (rounded.sign == NUMERIC_NEG);
- val = -digits[0];
- =====================================================================
- Found a 30 line (100 tokens) duplication in the following files:
- Starting at line 4765 of /home/shackle/pggit/postgresql/src/backend/utils/adt/timestamp.c
- Starting at line 4937 of /home/shackle/pggit/postgresql/src/backend/utils/adt/timestamp.c
- case DTK_MICROSEC:
- result = tm->tm_sec * 1000000.0 + fsec;
- break;
- case DTK_MILLISEC:
- result = tm->tm_sec * 1000.0 + fsec / 1000.0;
- break;
- case DTK_SECOND:
- result = tm->tm_sec + fsec / 1000000.0;
- break;
- case DTK_MINUTE:
- result = tm->tm_min;
- break;
- case DTK_HOUR:
- result = tm->tm_hour;
- break;
- case DTK_DAY:
- result = tm->tm_mday;
- break;
- case DTK_MONTH:
- result = tm->tm_mon;
- break;
- case DTK_QUARTER:
- result = (tm->tm_mon - 1) / 3 + 1;
- =====================================================================
- Found a 23 line (100 tokens) duplication in the following files:
- Starting at line 2454 of /home/shackle/pggit/postgresql/src/backend/commands/typecmds.c
- Starting at line 2673 of /home/shackle/pggit/postgresql/src/backend/commands/typecmds.c
- tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(domainoid));
- if (!HeapTupleIsValid(tup))
- elog(ERROR, "cache lookup failed for type %u", domainoid);
- /* Check it's a domain and check user has permission for ALTER DOMAIN */
- checkDomainOwner(tup);
- /* Grab an appropriate lock on the pg_constraint relation */
- conrel = heap_open(ConstraintRelationId, RowExclusiveLock);
- /* Find and remove the target constraint */
- ScanKeyInit(&skey[0],
- Anum_pg_constraint_conrelid,
- BTEqualStrategyNumber, F_OIDEQ,
- ObjectIdGetDatum(InvalidOid));
- ScanKeyInit(&skey[1],
- Anum_pg_constraint_contypid,
- BTEqualStrategyNumber, F_OIDEQ,
- ObjectIdGetDatum(domainoid));
- ScanKeyInit(&skey[2],
- Anum_pg_constraint_conname,
- BTEqualStrategyNumber, F_NAMEEQ,
- CStringGetDatum(constrName));
- =====================================================================
- Found a 26 line (100 tokens) duplication in the following files:
- Starting at line 6092 of /home/shackle/pggit/postgresql/src/backend/commands/tablecmds.c
- Starting at line 6246 of /home/shackle/pggit/postgresql/src/backend/commands/tablecmds.c
- ColumnDef *cdef = castNode(ColumnDef, def);
- attrelation = heap_open(AttributeRelationId, RowExclusiveLock);
- tuple = SearchSysCacheCopyAttName(RelationGetRelid(rel), colName);
- if (!HeapTupleIsValid(tuple))
- ereport(ERROR,
- (errcode(ERRCODE_UNDEFINED_COLUMN),
- errmsg("column \"%s\" of relation \"%s\" does not exist",
- colName, RelationGetRelationName(rel))));
- attTup = (Form_pg_attribute) GETSTRUCT(tuple);
- attnum = attTup->attnum;
- /* Can't alter a system attribute */
- if (attnum <= 0)
- ereport(ERROR,
- (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("cannot alter system column \"%s\"",
- colName)));
- /*
- * Creating a column as identity implies NOT NULL, so adding the identity
- * to an existing column that is not NOT NULL would create a state that
- * cannot be reproduced without contortions.
- */
- if (!attTup->attnotnull)
Add Comment
Please, Sign In to add comment