~ubuntu-branches/ubuntu/precise/libdbd-pg-perl/precise

« back to all changes in this revision

Viewing changes to dbdimp.c

  • Committer: Bazaar Package Importer
  • Author(s): Gunnar Wolf
  • Date: 2008-06-06 12:55:26 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20080606125526-bz1nh7rmt7bpf12w
Tags: 2.8.0-1
* New upstream release
* Added myself as an uploader

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 
3
 
  $Id: dbdimp.c 11266 2008-05-14 13:08:45Z turnstep $
 
3
  $Id: dbdimp.c 11357 2008-06-01 02:32:53Z turnstep $
4
4
 
5
5
  Copyright (c) 2002-2008 Greg Sabino Mullane and others: see the Changes file
6
6
  Portions Copyright (c) 2002 Jeffrey W. Baker
152
152
                strcat(conn_str, "'");
153
153
        }
154
154
 
155
 
        /* Close any old connection and free memory, just in case */
156
 
        if (imp_dbh->conn) {
157
 
                TRACE_PQFINISH;
158
 
                PQfinish(imp_dbh->conn);
159
 
        }
160
 
        
161
155
        /* Remove any stored savepoint information */
162
156
        if (imp_dbh->savepoints) {
163
157
                av_undef(imp_dbh->savepoints);
165
159
        }
166
160
        imp_dbh->savepoints = newAV(); /* freed in dbd_db_destroy */
167
161
 
 
162
        /* Close any old connection and free memory, just in case */
 
163
        if (imp_dbh->conn) {
 
164
                TRACE_PQFINISH;
 
165
                PQfinish(imp_dbh->conn);
 
166
        }
 
167
        
168
168
        /* Attempt the connection to the database */
169
169
        if (TLOGIN) TRC(DBILOGFP, "%sLogin connection string: (%s)\n", THEADER, conn_str);
170
170
        TRACE_PQCONNECTDB;
1194
1194
        case 8: /* pg_async */
1195
1195
 
1196
1196
                if (strEQ("pg_async", key)) {
1197
 
                        imp_sth->async_flag = SvIV(valuesv);
 
1197
                        imp_sth->async_flag = (int)SvIV(valuesv);
1198
1198
                        retval = 1;
1199
1199
                }
1200
1200
                break;
1305
1305
        ret=newAV();
1306
1306
        av_push(ret, newSVpv(notify->relname,0) );
1307
1307
        av_push(ret, newSViv(notify->be_pid) );
 
1308
        av_push(ret, newSVpv(notify->extra,0) );
 
1309
        /* Think about utf-8 in payloads someday... */
1308
1310
        
1309
1311
        TRACE_PQFREEMEM;
1310
1312
        PQfreemem(notify);
1364
1366
        /* Parse and set any attributes passed in */
1365
1367
        if (attribs) {
1366
1368
                if ((svp = hv_fetch((HV*)SvRV(attribs),"pg_server_prepare", 17, 0)) != NULL) {
1367
 
                        int newval = SvIV(*svp);
 
1369
                        int newval = (int)SvIV(*svp);
1368
1370
                        /* Default to "2" if an invalid value is passed in */
1369
1371
                        imp_sth->server_prepare = 0==newval ? 0 : 1==newval ? 1 : 2;
1370
1372
                }
1377
1379
                        imp_sth->dollaronly = SvTRUE(*svp) ? DBDPG_TRUE : DBDPG_FALSE;
1378
1380
                }
1379
1381
                if ((svp = hv_fetch((HV*)SvRV(attribs),"pg_async", 8, 0)) != NULL) {
1380
 
                  imp_sth->async_flag = SvIV(*svp);
 
1382
                        imp_sth->async_flag = (int)SvIV(*svp);
1381
1383
                }
1382
1384
        }
1383
1385
 
1909
1911
                TRC(DBILOGFP, "%sPlaceholder numbers, ph id, and segments:\n",
1910
1912
                        THEADER);
1911
1913
                for (currseg=imp_sth->seg; NULL != currseg; currseg=currseg->nextseg) {
1912
 
                        TRC(DBILOGFP, "%sPH: (%d) ID: (%d) SEG: (%s)\n",
1913
 
                                THEADER, currseg->placeholder, NULL==currseg->ph ? 0 : (int)currseg->ph, currseg->segment);
 
1914
                        TRC(DBILOGFP, "%sPH: (%d) SEG: (%s)\n",
 
1915
                                THEADER, currseg->placeholder, currseg->segment);
1914
1916
                }
1915
1917
                TRC(DBILOGFP, "%sPlaceholder number, fooname, id:\n", THEADER);
1916
1918
                for (xlen=1,currph=imp_sth->ph; NULL != currph; currph=currph->nextph,xlen++) {
1917
 
                        TRC(DBILOGFP, "%s#%d FOONAME: (%s) ID: (%d)\n",
1918
 
                                THEADER, xlen, currph->fooname, (int)currph);
 
1919
                        TRC(DBILOGFP, "%s#%d FOONAME: (%s)\n",
 
1920
                                THEADER, xlen, currph->fooname);
1919
1921
                }
1920
1922
        }
1921
1923
 
2200
2202
        /* Check for a pg_type argument (sql_type already handled) */
2201
2203
        if (attribs) {
2202
2204
                if((svp = hv_fetch((HV*)SvRV(attribs),"pg_type", 7, 0)) != NULL)
2203
 
                        pg_type = SvIV(*svp);
 
2205
                        pg_type = (int)SvIV(*svp);
2204
2206
        }
2205
2207
        
2206
2208
        if (sql_type && pg_type)
2212
2214
        if (pg_type) {
2213
2215
                if ((currph->bind_type = pg_type_data(pg_type))) {
2214
2216
                        if (!currph->bind_type->bind_ok) { /* Re-evaluate with new prepare */
2215
 
                                croak("Cannot bind %s, sql_type %s not supported by DBD::Pg",
 
2217
                                croak("Cannot bind %s, pg_type %s not supported by DBD::Pg",
2216
2218
                                          name, currph->bind_type->type_name);
2217
2219
                        }
2218
2220
                }
2352
2354
                        done = 1;
2353
2355
        }
2354
2356
 
2355
 
        inner_arrays = array_depth ? 1+av_len(lastarr) : 0;
 
2357
        inner_arrays = array_depth ? 1+(int)av_len(lastarr) : 0;
2356
2358
 
2357
2359
        /* How many items are in each inner array? */
2358
 
        array_items = array_depth ? (1+av_len((AV*)SvRV(*av_fetch(lastarr,0,0)))) : 1+av_len(lastarr);
 
2360
        array_items = array_depth ? (1+(int)av_len((AV*)SvRV(*av_fetch(lastarr,0,0)))) : 1+(int)av_len(lastarr);
2359
2361
 
2360
2362
        for (xy=1; xy < array_depth; xy++) {
2361
2363
                sv_catpv(value, "{");
3201
3203
        av = DBIS->get_fbav(imp_sth);
3202
3204
        num_fields = AvFILL(av)+1;
3203
3205
        
3204
 
        chopblanks = DBIc_has(imp_sth, DBIcf_ChopBlanks);
 
3206
        chopblanks = (int)DBIc_has(imp_sth, DBIcf_ChopBlanks);
3205
3207
 
3206
3208
        /* Set up the type_info array if we have not seen it yet */
3207
3209
        if (NULL == imp_sth->type_info) {
3350
3352
        dTHX;
3351
3353
        D_imp_dbh_from_sth;
3352
3354
 
3353
 
        if (TSTART) TRC(DBILOGFP, "%sBegin dbdpg_finish (sth: %d async: %d)\n",
3354
 
                                        THEADER, (int)sth, imp_dbh->async_status);
 
3355
        if (TSTART) TRC(DBILOGFP, "%sBegin dbdpg_finish (async: %d)\n",
 
3356
                                        THEADER, imp_dbh->async_status);
3355
3357
        
3356
3358
        if (DBIc_ACTIVE(imp_sth) && imp_sth->result) {
3357
3359
                TRACE_PQCLEAR;