[HACKERS] Login/logout
Hello all I want to register in an audit table the date and time of the login/logout of a database user. I have been looking for some function in the code but I didn't find something like that. Can you give me some ideas to implement it?. I'm ready to program if it is necessary. Thanks in advance, regards Juan P. Espino ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly
Re: [HACKERS] Login/logout
Thanks for the quick response. Yes I want to retrieve the login/logout info, but I want to insert this info in a table that I use as an audit table. Regards Juan P. Espino On 6/18/05, Michael Fuhr [EMAIL PROTECTED] wrote: On Sat, Jun 18, 2005 at 11:11:31AM -0500, Juan Pablo Espino wrote: I want to register in an audit table the date and time of the login/logout of a database user. I have been looking for some function in the code but I didn't find something like that. Are you interested in logging to a table specifically, or are you just trying to get the login/logout info? If the latter, then you can use log_connections and log_disconnections (the second of which is available in 8.0 and later). http://www.postgresql.org/docs/8.0/static/runtime-config.html#RUNTIME-CONFIG-LOGGING-WHAT -- Michael Fuhr http://www.fuhr.org/~mfuhr/ ---(end of broadcast)--- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match
Re: [HACKERS] Login/logout
Hi, thanks for the response. On 6/18/05, Rod Taylor [EMAIL PROTECTED] wrote: On Sat, 2005-06-18 at 11:46 -0500, Juan Pablo Espino wrote: Thanks for the quick response. Yes I want to retrieve the login/logout info, but I want to insert this info in a table that I use as an audit table. Regards I suggest putting together a short script to scan the logs periodically and add the new entries to your table. It sounds to me good in order to resolve my problem. Nevertheless I think that it would be very useful to have a function that does something like select login() and gives back to the date and time of login, or that we can retrieve that info from the system catalogs. Regards, Juan P. Espino ---(end of broadcast)--- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match
[HACKERS] C array from SQL array?
Hello hackers At the moment I need to pass from a SQL array to a C array. I have the following table: CREATE TABLE emps ( name text, array int4[] ) For example, array have this values: {4000,1,0,0} I wrote this function for test in order to see something that could help me: extern Datum vector(PG_FUNCTION_ARGS); PG_FUNCTION_INFO_V1(vector); Datum vector(PG_FUNCTION_ARGS) { text*table_text = PG_GETARG_TEXT_P(0); TupleDesc tupdesc; boolisnull; char*table_char, *type, *cmd; int n1, ret; table_char = text_2_char(table_text); /* pass text to c string */ cmd = (char *) palloc(14 + strlen(table_char) + 1); tupdesc = (TupleDesc) RelationNameGetTupleDesc(table_char); sprintf(cmd, select * from %s, table_char); SPI_connect(); type = SPI_gettype(tupdesc, 2); /* to obtain the c data type of the sql array?? */ ret = SPI_exec(cmd, 0); /* for this test I take only the first table row */ n1 = DatumGetInt32(SPI_getbinval(SPI_tuptable-vals[0], SPI_tuptable-tupdesc, 2, isnull)); SPI_finish(); elog(INFO, The data type of the column no. 2 is %s and its value is %d, type, n1); return PointerGetDatum(ret); } Then, the result of the select vector('emps'); was INFO: The data type of the column no. 2 is _int4 and its value is 137606808 I wanted that n1 collects the data of the SQL array. I really appreciate any suggestions, thanks in advance, regards. Juan P. Espino PS. I ignore if the term I'm using SQL array is correct. ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]
[HACKERS] Returning the name of a primary key
Hello all I need to write a function that retrieve the name of at least one table primary key, if it exists. The only argument passed to the function is the table name. I have thought something like this: char * give_pkey(char * table_char) TupleDesc tupdesc; Form_pg_attribute att; Form_pg_index ind; int i, c=0, temp=-1; tupdesc = (TupleDesc) RelationNameGetTupleDesc(tabla_char); ind = something that idicates which table is for (i=0; i(tupdesc-natts); i++) { att = tupdesc-attrs[i]; c = c + 1; /* Something that can compare each attribute to determine if it is a primary key ?*/ if ((ind-indisprimary) (temp=-1)) { temp = c; att = tupdesc-attrs[temp]; } } return pstrdup(NameStr(att-attname)); } Sorry, I don't have much experience in c programming, thanks in advance for any suggestions, regards, Juan P. Espino ---(end of broadcast)--- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match
[HACKERS] Understanding Rule System
Hello all I have been studying the rule system in Postgres. I understand that the original query tree is the input at the rewrite, and then this query tree is modified by the rewrite in case that there is a rule. SQL query Parser Rewrite Planner Executor Query New Query treetree I would like to know how the rewrite detects that a rule in a table exists, and if it possible you indicate me where in the source code it's implemented. Any comments are welcome, thanks in advance. Juan P. Espino ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster
Re: [HACKERS] Another history question
Thanks for the explanation. Then, Can I say that PostgreSQL and Informix are cousins? On Tue, 22 Mar 2005 17:36:28 -0500, Tom Lane [EMAIL PROTECTED] wrote: Juan Pablo Espino [EMAIL PROTECTED] writes: My question is if the architecture of postgreSQL were inherited of postgres original project or postgreSQL were developed completely with a new concept. Thanks in advance. There hasn't been any fundamental rearchitecting since Berkeley days. For instance, look at Postgres 4.2 --- those sources are available on the net, and if you compare them to current CVS you'll find plenty that's recognizably the same code. regards, tom lane ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]
[HACKERS] Another history question
I know that postgres was a project directed by Michael Stonebraker in Berkeley (1986-1994) and that soon Jolly Chen and Andrew Yu did postgres95. I understand that the main change in postgres95 was to implement SQL instead of POSTQUEL. Then after the appearance of postgres95 postgreSQL 6.0 arises. And what came later it is well-known history. My question is if the architecture of postgreSQL were inherited of postgres original project or postgreSQL were developed completely with a new concept. Thanks in advance. ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster
[HACKERS]
set pgsql-hackers nomail ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly
Re: [HACKERS]
Sorry it was for [EMAIL PROTECTED] On Thu, 17 Mar 2005 18:08:03 -0500, Juan Pablo Espino [EMAIL PROTECTED] wrote: set pgsql-hackers nomail ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly ---(end of broadcast)--- TIP 2: you can get off all lists at once with the unregister command (send unregister YourEmailAddressHere to [EMAIL PROTECTED])