Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 377939
Collapse All | Expand All

(-)vpgsql.c.2 (-4 / +62 lines)
Lines 392-401 Link Here
392
#endif
392
#endif
393
393
394
#ifdef ENABLE_SQL_LOGGING
394
#ifdef ENABLE_SQL_LOGGING
395
    qnprintf( sqlBufUpdate, SQL_BUF_SIZE,
395
    qnprintf( SqlBufUpdate, SQL_BUF_SIZE,
396
       "delete from vlog where domain = '%s'", domain );
396
       "delete from vlog where domain = '%s'", domain );
397
    pgres=PQexec(pgc, SqlBufUpdate);
397
    pgres=PQexec(pgc, SqlBufUpdate);
398
    if( !pgres || PGresultStatus(pgres)!=PGRES_COMMAND_OK) {
398
    if( !pgres || PQresultStatus(pgres)!=PGRES_COMMAND_OK) {
399
      return(-1);
399
      return(-1);
400
    }
400
    }
401
#endif
401
#endif
Lines 445-455 Link Here
445
#endif
445
#endif
446
446
447
#ifdef ENABLE_SQL_LOGGING
447
#ifdef ENABLE_SQL_LOGGING
448
    qnprintf( sqlBufUpdate, SQL_BUF_SIZE,
448
    qnprintf( SqlBufUpdate, SQL_BUF_SIZE,
449
        "delete from vlog where domain = '%s' and user='%s'", 
449
        "delete from vlog where domain = '%s' and user='%s'", 
450
       domain, user );
450
       domain, user );
451
    pgres=PQexec(pgc, SqlBufUpdate);
451
    pgres=PQexec(pgc, SqlBufUpdate);
452
    if( !pgres || PGresultStatus(pgres)!=PGRES_COMMAND_OK) {
452
    if( !pgres || PQresultStatus(pgres)!=PGRES_COMMAND_OK) {
453
      err = -1;
453
      err = -1;
454
    }
454
    }
455
#endif
455
#endif
Lines 1555-1560 Link Here
1555
    return valias_current->data; 
1555
    return valias_current->data; 
1556
  }
1556
  }
1557
}
1557
}
1558
1559
char *valias_select_names( char *alias, char *domain )
1560
{
1561
	PGresult *pgres;
1562
	int err;
1563
	unsigned ntuples, ctuple;
1564
	struct linklist *temp_entry = NULL;
1565
1566
	/* remove old entries as necessary */
1567
	while (valias_current != NULL)
1568
		valias_current = linklist_del (valias_current);
1569
1570
	if ( (err =vauth_open(0)) != 0 ) return (NULL);
1571
1572
	qnprintf( SqlBufRead, SQL_BUF_SIZE,
1573
		"select distinct alias from valias where domain = '%s' order by alias", domain);
1574
	if ( ! (pgres=PQexec(pgc, SqlBufRead))
1575
		|| PQresultStatus(pgres) != PGRES_TUPLES_OK ) {
1576
		if(pgres) PQclear(pgres);
1577
		vcreate_valias_table();
1578
		if ( ! (pgres=PQexec(pgc, SqlBufRead))
1579
			|| PQresultStatus(pgres) != PGRES_TUPLES_OK ) {
1580
				fprintf(stderr,"vpgsql: sql error[o]: %s\n",
1581
				PQerrorMessage(pgc));
1582
				if (pgres) PQclear (pgres);
1583
				return(NULL);
1584
		}
1585
	}
1586
	ntuples = PQntuples (pgres);
1587
	for (ctuple = 0; ctuple < ntuples; ctuple++) {
1588
		temp_entry = linklist_add (temp_entry, PQgetvalue (pgres, ctuple, 1), PQgetvalue (pgres, ctuple, 0));
1589
		if (valias_current == NULL) valias_current = temp_entry;
1590
	}
1591
	PQclear (pgres);
1592
	pgres = NULL; 
1593
1594
	if (valias_current == NULL) return NULL; /* no results */
1595
	else {
1596
		strcpy (alias, valias_current->d2);
1597
		return(valias_current->data);
1598
	}
1599
}
1600
1601
char *valias_select_names_next(char *alias)
1602
{
1603
	if (valias_current == NULL) return NULL;
1604
	valias_current = linklist_del (valias_current);
1605
1606
	if (valias_current == NULL) return NULL; /* no results */
1607
	else {
1608
		strcpy(alias, valias_current->d2);
1609
		return(valias_current->data);
1610
	}
1611
}
1612
1613
void valias_select_names_end() {
1614
	// not needed with PostgreSQL
1615
}
1558
#endif
1616
#endif
1559
1617
1560
#ifdef ENABLE_SQL_LOGGING
1618
#ifdef ENABLE_SQL_LOGGING

Return to bug 377939