X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id C6F57D1B528 for ; Tue, 23 Sep 2003 16:18:48 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 14744-06 for ; Tue, 23 Sep 2003 13:18:38 -0300 (ADT) Received: from lame.novel.ru (dialup199-2.fannet.ru [217.23.67.199]) by svr1.postgresql.org (Postfix) with ESMTP id 55557D1B4F1 for ; Tue, 23 Sep 2003 13:18:36 -0300 (ADT) Received: from lame.novel.ru (lame.novel.ru [127.0.0.1]) by lame.novel.ru (8.12.9/8.12.9) with SMTP id h8NGHo13001143 for ; Tue, 23 Sep 2003 20:17:52 +0400 (MSD) (envelope-from bogorodskiy@inbox.ru) Date: Tue, 23 Sep 2003 20:17:50 +0400 From: Roman Bogorodskiy To: pgsql-interfaces@postgresql.org Subject: troubles with getting data from tables Message-Id: <20030923201750.7cacf851.bogorodskiy@inbox.ru> X-Mailer: Reality Is Illusion Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200309/58 X-Sequence-Number: 4476 pgsql-interfaces@ I'm writing a backend for some ftp demon on C. I want to make it possible to authorize server's clients via pgsql. And I have a such problem: I have a function FCN_VALIDATE_LOGIN which checks if a given users name is ok. It's looks like this (I've removed some debug code) : ---cut 8<--- int FCN_VALIDATE_LOGIN (const char *login) { PGresult *res; char *query; query = malloc(256); sprintf(query, "SELECT * FROM users WHERE name=\'%s\';", login); res = PQexec(conn, query); if (!res || PQresultStatus(res) != PGRES_TUPLES_OK) { fprintf(stderr, "%s\n", PQresultErrorMessage(conn)); printf("Error\n"); } if (PQntuples(res) == 1) { int uid_field_index; unsigned int *uid; uid_field_index = PQfnumber(res, "uid"); uid = (int *) PQgetvalue(res, 0, uid_field_index); #ifdef DEBUG fprintf(stderr, "uid_field_index = %i\n uid %i\n", uid_field_index, uid); #endif // return uid; } else { // Not such user return -1; } PQclear(res); } ---cut 8<--- And I have a such table: ---cut 8<--- CREATE TABLE users ( name character varying NOT NULL, passwd character varying, home character varying, groups character varying NOT NULL, rights character varying NOT NULL, uid int4 NOT NULL, ip_allowed character varying, max_dl_speed integer, bytes_ul_total bigint, bytes_dl_total bigint, ratio integer, flags character varying, user_slots integer, leech_slots integer ); ---cut 8<--- I have only one row in this table where uid is '1001'. wzdftpd=# select uid from users; uid ------ 1001 (1 row) But instead of '1001' "uid" value is '134820376'. Where I was wrong? -Roman Bogorodskiy [Novel]