~kampka/ubuntu/quantal/zabbix/upstart-support

« back to all changes in this revision

Viewing changes to src/libs/zbxdb/db.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Ablassmeier
  • Date: 2009-06-28 19:11:29 UTC
  • mfrom: (19.1.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090628191129-5esmmf2h3tbff1fv
* New upstream release
* Merge upstream config file to template (Closes: #528426)
* Move logrotate from Depends to Suggests (Closes: #534096)
* Server should not crash anymore if postgresql transaction fails
  (Closes: #520197)
* Update fr.po (Closes: #527559)
* Update es.po (Closes: #527600)
* Update sv.po (Closes: #528571)
* Update it.po (Closes: #529157)
* Update cs.po (Closes: #529502)
* Update de.po (Closes: #532344)

Show diffs side-by-side

added added

removed removed

Lines of Context:
122
122
        char            *cport = NULL;
123
123
        DB_RESULT       result;
124
124
        DB_ROW          row;
 
125
        int             sversion;
125
126
 
126
127
        if( port )      cport = zbx_dsprintf(cport, "%i", port);
127
128
 
144
145
        }
145
146
        DBfree_result(result);
146
147
 
 
148
#ifdef  HAVE_FUNCTION_PQSERVERVERSION
 
149
        sversion = PQserverVersion(conn);
 
150
        zabbix_log(LOG_LEVEL_DEBUG, "PostgreSQL Server version: %d", sversion);
 
151
#else
 
152
        sversion = 0;
 
153
#endif  /* HAVE_FUNCTION_PQSERVERVERSION */
 
154
 
 
155
        if (sversion >= 80100)
 
156
        {
 
157
                /* disable "nonstandard use of \' in a string literal" warning */
 
158
                DBexecute("set escape_string_warning to off");
 
159
        }
 
160
 
147
161
        return ret;
148
162
#endif
149
163
#ifdef  HAVE_ORACLE
721
735
#endif
722
736
#ifdef  HAVE_POSTGRESQL
723
737
        result = zbx_malloc(NULL, sizeof(ZBX_PG_DB_RESULT));
724
 
        result->pg_result = PQexec(conn,sql);
 
738
        result->pg_result = PQexec(conn, sql);
725
739
        result->values = NULL;
726
740
        result->cursor = 0;
 
741
        result->row_num = 0;
727
742
 
728
 
        if(result->pg_result==NULL)
 
743
        if (NULL == result->pg_result)
729
744
        {
730
745
                zabbix_errlog(ERR_Z3005, 0, "Result is NULL", sql);
731
 
                exit(FAIL);
732
746
        }
733
 
        if( PQresultStatus(result->pg_result) != PGRES_TUPLES_OK)
 
747
        if (PGRES_TUPLES_OK != PQresultStatus(result->pg_result))
734
748
        {
735
749
                error = zbx_dsprintf(error, "%s:%s",
736
750
                                PQresStatus(PQresultStatus(result->pg_result)),
737
751
                                PQresultErrorMessage(result->pg_result));
738
752
                zabbix_errlog(ERR_Z3005, 0, error, sql);
739
753
                zbx_free(error);
740
 
                exit(FAIL);
741
754
        }
742
 
        
743
 
        /* init rownum */       
744
 
        result->row_num = PQntuples(result->pg_result);
 
755
        else    /* init rownum */
 
756
                result->row_num = PQntuples(result->pg_result);
745
757
 
746
758
#endif
747
759
#ifdef  HAVE_ORACLE