~ubuntu-branches/ubuntu/natty/postgresql-8.4/natty-security

« back to all changes in this revision

Viewing changes to src/interfaces/libpq/fe-exec.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-07-11 16:59:35 UTC
  • mfrom: (5.1.1 karmic)
  • Revision ID: james.westby@ubuntu.com-20090711165935-jfwin6gfrxf0gfsi
Tags: 8.4.0-2
* debian/libpq-dev.install: Ship catalog/genbki.h. (Closes: #536139)
* debian/rules: Drop --enable-cassert for final release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
 *
9
9
 *
10
10
 * IDENTIFICATION
11
 
 *        $PostgreSQL: pgsql/src/interfaces/libpq/fe-exec.c,v 1.200 2009/01/01 17:24:03 momjian Exp $
 
11
 *        $PostgreSQL: pgsql/src/interfaces/libpq/fe-exec.c,v 1.203 2009/06/11 14:49:13 momjian Exp $
12
12
 *
13
13
 *-------------------------------------------------------------------------
14
14
 */
64
64
static PGresult *PQexecFinish(PGconn *conn);
65
65
static int PQsendDescribe(PGconn *conn, char desc_type,
66
66
                           const char *desc_target);
67
 
static int check_field_number(const PGresult *res, int field_num);
 
67
static int      check_field_number(const PGresult *res, int field_num);
68
68
 
69
69
 
70
70
/* ----------------
218
218
int
219
219
PQsetResultAttrs(PGresult *res, int numAttributes, PGresAttDesc *attDescs)
220
220
{
221
 
        int i;
 
221
        int                     i;
222
222
 
223
223
        /* If attrs already exist, they cannot be overwritten. */
224
224
        if (!res || res->numAttributes > 0)
262
262
 * Returns a deep copy of the provided 'src' PGresult, which cannot be NULL.
263
263
 * The 'flags' argument controls which portions of the result will or will
264
264
 * NOT be copied.  The created result is always put into the
265
 
 * PGRES_TUPLES_OK status.  The source result error message is not copied,
 
265
 * PGRES_TUPLES_OK status.      The source result error message is not copied,
266
266
 * although cmdStatus is.
267
267
 *
268
 
 * To set custom attributes, use PQsetResultAttrs.  That function requires
 
268
 * To set custom attributes, use PQsetResultAttrs.      That function requires
269
269
 * that there are no attrs contained in the result, so to use that
270
270
 * function you cannot use the PG_COPYRES_ATTRS or PG_COPYRES_TUPLES
271
271
 * options with this function.
272
272
 *
273
273
 * Options:
274
 
 *   PG_COPYRES_ATTRS - Copy the source result's attributes
275
 
 *
276
 
 *   PG_COPYRES_TUPLES - Copy the source result's tuples.  This implies
277
 
 *   copying the attrs, seeeing how the attrs are needed by the tuples.
278
 
 *
279
 
 *   PG_COPYRES_EVENTS - Copy the source result's events.
280
 
 *
281
 
 *   PG_COPYRES_NOTICEHOOKS - Copy the source result's notice hooks.
 
274
 *       PG_COPYRES_ATTRS - Copy the source result's attributes
 
275
 *
 
276
 *       PG_COPYRES_TUPLES - Copy the source result's tuples.  This implies
 
277
 *       copying the attrs, seeeing how the attrs are needed by the tuples.
 
278
 *
 
279
 *       PG_COPYRES_EVENTS - Copy the source result's events.
 
280
 *
 
281
 *       PG_COPYRES_NOTICEHOOKS - Copy the source result's notice hooks.
282
282
 */
283
283
PGresult *
284
284
PQcopyResult(const PGresult *src, int flags)
285
285
{
286
 
        PGresult *dest;
287
 
        int i;
 
286
        PGresult   *dest;
 
287
        int                     i;
288
288
 
289
289
        if (!src)
290
290
                return NULL;
293
293
        if (!dest)
294
294
                return NULL;
295
295
 
296
 
        /* Always copy these over.  Is cmdStatus really useful here? */
 
296
        /* Always copy these over.      Is cmdStatus really useful here? */
297
297
        dest->client_encoding = src->client_encoding;
298
298
        strcpy(dest->cmdStatus, src->cmdStatus);
299
299
 
310
310
        /* Wants to copy tuples? */
311
311
        if (flags & PG_COPYRES_TUPLES)
312
312
        {
313
 
                int tup, field;
 
313
                int                     tup,
 
314
                                        field;
314
315
 
315
316
                for (tup = 0; tup < src->ntups; tup++)
316
317
                {
373
374
static PGEvent *
374
375
dupEvents(PGEvent *events, int count)
375
376
{
376
 
        PGEvent *newEvents;
377
 
        int i;
 
377
        PGEvent    *newEvents;
 
378
        int                     i;
378
379
 
379
380
        if (!events || count <= 0)
380
381
                return NULL;
424
425
        /* need to grow the tuple table? */
425
426
        if (res->ntups >= res->tupArrSize)
426
427
        {
427
 
                int n = res->tupArrSize ? res->tupArrSize * 2 : 128;
 
428
                int                     n = res->tupArrSize ? res->tupArrSize * 2 : 128;
428
429
                PGresAttValue **tups;
429
430
 
430
431
                if (res->tuples)
445
446
        if (tup_num == res->ntups && !res->tuples[tup_num])
446
447
        {
447
448
                PGresAttValue *tup;
448
 
                int i;
 
449
                int                     i;
449
450
 
450
451
                tup = (PGresAttValue *)
451
452
                        pqResultAlloc(res, res->numAttributes * sizeof(PGresAttValue),
661
662
PQclear(PGresult *res)
662
663
{
663
664
        PGresult_data *block;
664
 
        int i;
 
665
        int                     i;
665
666
 
666
667
        if (!res)
667
668
                return;
1600
1601
 
1601
1602
        if (res)
1602
1603
        {
1603
 
                int i;
 
1604
                int                     i;
1604
1605
 
1605
1606
                for (i = 0; i < res->nEvents; i++)
1606
1607
                {
3115
3116
        {
3116
3117
                if (*vp < 0x20 || *vp > 0x7e)
3117
3118
                {
3118
 
                        int             val = *vp;
 
3119
                        int                     val = *vp;
3119
3120
 
3120
3121
                        if (!std_strings)
3121
3122
                                *rp++ = '\\';
3219
3220
                                                (ISOCTDIGIT(strtext[i + 1])) &&
3220
3221
                                                (ISOCTDIGIT(strtext[i + 2])))
3221
3222
                                        {
3222
 
                                                int                     byte;
 
3223
                                                int byte;
3223
3224
 
3224
3225
                                                byte = OCTVAL(strtext[i++]);
3225
 
                                                byte = (byte << 3) + OCTVAL(strtext[i++]);
3226
 
                                                byte = (byte << 3) + OCTVAL(strtext[i++]);
 
3226
                                                byte = (byte <<3) +OCTVAL(strtext[i++]);
 
3227
                                                byte = (byte <<3) +OCTVAL(strtext[i++]);
3227
3228
                                                buffer[j++] = byte;
3228
3229
                                        }
3229
3230
                                }