Diff for /sql/pgsql/parser3pgsql.C between versions 1.49 and 1.50

version 1.49, 2021/11/03 16:27:15 version 1.50, 2021/11/07 22:16:54
Line 140  public: Line 140  public:
                 char* host=rsplit(user, '@');                  char* host=rsplit(user, '@');
                 char* db=lsplit(host, '/');                  char* db=lsplit(host, '/');
                 char* pwd=lsplit(user, ':');                  char* pwd=lsplit(user, ':');
                 char* port=lsplit(host, ':');  
   
                 char *options=lsplit(db, '?');                  char *options=lsplit(db, '?');
   
                 char* charset=0;                  char* charset=0;
                 char* datestyle=0;                  char* datestyle=0;
   
                   char* pq_options=0;
                   size_t  pq_options_len=options ? strlen(options) : 0;
   
                 Connection& connection=*(Connection *)services.malloc(sizeof(Connection));                  Connection& connection=*(Connection *)services.malloc(sizeof(Connection));
   
                 *connection_ref=&connection;                  *connection_ref=&connection;
Line 172  public: Line 174  public:
                                                 } else if(strcasecmp(key, "standard_conforming_strings")==0){                                                  } else if(strcasecmp(key, "standard_conforming_strings")==0){
                                                         if(atoi(value)==0)                                                          if(atoi(value)==0)
                                                                 connection.standard_conforming_strings=false;                                                                  connection.standard_conforming_strings=false;
                                                 } else                                                  } else {
                                                         services._throw("unknown connect option" /*key*/);                                                          if(!pq_options) {
                                                                   pq_options=(char*)services.malloc_atomic(pq_options_len+2);
                                                                   strcpy(pq_options, "?");
                                                           } else {
                                                                   strcat(pq_options, "&");
                                                           }
                                                           strcat(pq_options, key);
                                                           strcat(pq_options, "=");
                                                           strcat(pq_options, value);
                                                   }
                                         } else                                           } else 
                                                 services._throw("connect option without =value" /*key*/);                                                  services._throw("connect option without =value" /*key*/);
                                 }                                  }
                         }                          }
                 }                  }
   
                 connection.conn=PQsetdbLogin( (host && strcasecmp(host, "local") == 0) ? NULL /* local Unix domain socket */ : host, port, NULL, NULL, db, user, pwd);                  if(host && (strchr(host, ',') || pq_options)){ // pq_options can exist only if host and db are not null
                           char pq_url[MAX_STRING+1];
                           snprintf(pq_url, MAX_STRING, "postgresql://%s/%s%s", host, db ? db : "", pq_options ? pq_options : "");
                           connection.conn=PQsetdbLogin(NULL, NULL, NULL, NULL, pq_url, user, pwd);
                   } else {
                           char* port=lsplit(host, ':');
                           connection.conn=PQsetdbLogin( (host && strcasecmp(host, "local") == 0) ? NULL /* local Unix domain socket */ : host, port, NULL, NULL, db, user, pwd);
                   }
   
                 if(!connection.conn)                  if(!connection.conn)
                         services._throw("PQsetdbLogin failed");                          services._throw("PQsetdbLogin failed");
Line 203  public: Line 221  public:
                 }                  }
   
                 if(!connection.autocommit)                  if(!connection.autocommit)
                         _execute_cmd(connection, "set AUTOCOMMIT off");                          _execute_cmd(connection, "BEGIN");
         }          }
   
         void disconnect(void *aconnection){          void disconnect(void *aconnection){

Removed from v.1.49  
changed lines
  Added in v.1.50


E-mail: