One more time...  The last patch didn't have the unitialized variables
stuff in it.  Please disregard the previous patch and apply this one.

On Sat, 2003-11-29 at 00:34, Matthew T. O'Connor wrote:
> ARRRGGHH.... ok, with patch this time...
> 
> On Sat, 2003-11-29 at 00:17, Matthew T. O'Connor wrote:
> > Hello, 
> > 
> > I noticed that there have been a few patched submitted for pg_autovacuum
> > that have not been applied, so I applied them locally and tested them on
> > my Fedora box.  I am resubmitting them as one single patch.
> > 
> > Included in the attached patch:
> > 
> > Brian Hurt's patch that fixed the truncate bug by referencing a table
> > oid rather than it's relfilenode.
> > 
> > Craig Boston's patch that fixes crashes on FreeBSD related to
> > uninitialized variables.
> > 
> > A quick patch by me to remove a log_entry call inside init_table_info()
> > that was used for debugging by me during development and I left in by
> > mistake.
> > 
> > Please apply this patch to both HEAD and 7.4.
> > 
> > Thanks much,
> > 
> > Matthew O'Connor
> > 
> > 
> > 
> > ---------------------------(end of broadcast)---------------------------
> > TIP 5: Have you checked our extensive FAQ?
> > 
> >                http://www.postgresql.org/docs/faqs/FAQ.html
> > 
> 
> ______________________________________________________________________
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])
*** ./pg_autovacuum.c.orig	2003-11-28 23:27:46.000000000 -0500
--- ./pg_autovacuum.c	2003-11-28 23:27:21.000000000 -0500
***************
*** 116,126 ****
  		 atol(PQgetvalue(res, row, PQfnumber(res, "n_tup_upd"))));
  	new_tbl->curr_vacuum_count = new_tbl->CountAtLastVacuum;
  
! 	new_tbl->relfilenode = atoi(PQgetvalue(res, row, PQfnumber(res, "relfilenode")));
  	new_tbl->reltuples = atoi(PQgetvalue(res, row, PQfnumber(res, "reltuples")));
  	new_tbl->relpages = atoi(PQgetvalue(res, row, PQfnumber(res, "relpages")));
  
- 	log_entry(PQgetvalue(res, row, PQfnumber(res, "relisshared")));
  	if (strcmp("t", PQgetvalue(res, row, PQfnumber(res, "relisshared"))))
  		new_tbl->relisshared = 0;
  	else
--- 116,125 ----
  		 atol(PQgetvalue(res, row, PQfnumber(res, "n_tup_upd"))));
  	new_tbl->curr_vacuum_count = new_tbl->CountAtLastVacuum;
  
! 	new_tbl->relid = atoi(PQgetvalue(res, row, PQfnumber(res, "oid")));
  	new_tbl->reltuples = atoi(PQgetvalue(res, row, PQfnumber(res, "reltuples")));
  	new_tbl->relpages = atoi(PQgetvalue(res, row, PQfnumber(res, "relpages")));
  
  	if (strcmp("t", PQgetvalue(res, row, PQfnumber(res, "relisshared"))))
  		new_tbl->relisshared = 0;
  	else
***************
*** 154,160 ****
  
  	if (dbi->conn != NULL)
  	{
! 		snprintf(query, sizeof(query), PAGES_QUERY, tbl->relfilenode);
  		res = send_query(query, dbi);
  		if (res != NULL)
  		{
--- 153,159 ----
  
  	if (dbi->conn != NULL)
  	{
! 		snprintf(query, sizeof(query), PAGES_QUERY, tbl->relid);
  		res = send_query(query, dbi);
  		if (res != NULL)
  		{
***************
*** 237,243 ****
  			for (i = 0; i < t; i++)
  			{					/* loop through result set looking for a
  								 * match */
! 				if (tbl->relfilenode == atoi(PQgetvalue(res, i, PQfnumber(res, "relfilenode"))))
  				{
  					found_match = 1;
  					break;
--- 236,242 ----
  			for (i = 0; i < t; i++)
  			{					/* loop through result set looking for a
  								 * match */
! 				if (tbl->relid == atoi(PQgetvalue(res, i, PQfnumber(res, "oid"))))
  				{
  					found_match = 1;
  					break;
***************
*** 267,273 ****
  			while (tbl_elem != NULL)
  			{
  				tbl = ((tbl_info *) DLE_VAL(tbl_elem));
! 				if (tbl->relfilenode == atoi(PQgetvalue(res, i, PQfnumber(res, "relfilenode"))))
  				{
  					found_match = 1;
  					break;
--- 266,272 ----
  			while (tbl_elem != NULL)
  			{
  				tbl = ((tbl_info *) DLE_VAL(tbl_elem));
! 				if (tbl->relid == atoi(PQgetvalue(res, i, PQfnumber(res, "oid"))))
  				{
  					found_match = 1;
  					break;
***************
*** 361,367 ****
  {
  	sprintf(logbuffer, "  table name:     %s.%s", tbl->dbi->dbname, tbl->table_name);
  	log_entry(logbuffer);
! 	sprintf(logbuffer, "     relfilenode: %i;   relisshared: %i", tbl->relfilenode, tbl->relisshared);
  	log_entry(logbuffer);
  	sprintf(logbuffer, "     reltuples: %i;  relpages: %i", tbl->reltuples, tbl->relpages);
  	log_entry(logbuffer);
--- 360,366 ----
  {
  	sprintf(logbuffer, "  table name:     %s.%s", tbl->dbi->dbname, tbl->table_name);
  	log_entry(logbuffer);
! 	sprintf(logbuffer, "     relid: %i;   relisshared: %i", tbl->relid, tbl->relisshared);
  	log_entry(logbuffer);
  	sprintf(logbuffer, "     reltuples: %i;  relpages: %i", tbl->reltuples, tbl->relpages);
  	log_entry(logbuffer);
***************
*** 811,816 ****
--- 810,820 ----
  	args->analyze_scaling_factor = -1;
  	args->debug = AUTOVACUUM_DEBUG;
  	args->daemonize = 0;
+ 	args->user = 0;
+ 	args->password = 0;
+ 	args->host = 0;
+ 	args->logfile = 0;
+ 	args->port = 0;
  
  	/*
  	 * Fixme: Should add some sanity checking such as positive integer
***************
*** 1067,1073 ****
  						{		/* Loop through tables in list */
  							tbl = ((tbl_info *) DLE_VAL(tbl_elem));		/* set tbl_info =
  																		 * current_table */
! 							if (tbl->relfilenode == atoi(PQgetvalue(res, j, PQfnumber(res, "relfilenode"))))
  							{
  								tbl->curr_analyze_count =
  									(atol(PQgetvalue(res, j, PQfnumber(res, "n_tup_ins"))) +
--- 1071,1077 ----
  						{		/* Loop through tables in list */
  							tbl = ((tbl_info *) DLE_VAL(tbl_elem));		/* set tbl_info =
  																		 * current_table */
! 							if (tbl->relid == atoi(PQgetvalue(res, j, PQfnumber(res, "oid"))))
  							{
  								tbl->curr_analyze_count =
  									(atol(PQgetvalue(res, j, PQfnumber(res, "n_tup_ins"))) +
*** ./pg_autovacuum.h.orig	2003-11-28 23:27:52.000000000 -0500
--- ./pg_autovacuum.h	2003-11-28 23:25:55.000000000 -0500
***************
*** 34,43 ****
  #define VACUUM_ANALYZE		0
  #define ANALYZE_ONLY		1
  
! #define TABLE_STATS_QUERY	"select a.relfilenode,a.relname,a.relnamespace,a.relpages,a.relisshared,a.reltuples,b.schemaname,b.n_tup_ins,b.n_tup_upd,b.n_tup_del from pg_class a, pg_stat_all_tables b where a.relfilenode=b.relid and a.relkind = 'r'"
  
  #define FRONTEND
! #define PAGES_QUERY "select relfilenode,reltuples,relpages from pg_class where relfilenode=%i"
  #define FROZENOID_QUERY "select oid,age(datfrozenxid) from pg_database where datname = 'template1'"
  #define FROZENOID_QUERY2 "select oid,datname,age(datfrozenxid) from pg_database where datname!='template0'"
  
--- 34,43 ----
  #define VACUUM_ANALYZE		0
  #define ANALYZE_ONLY		1
  
! #define TABLE_STATS_QUERY	"select a.oid,a.relname,a.relnamespace,a.relpages,a.relisshared,a.reltuples,b.schemaname,b.n_tup_ins,b.n_tup_upd,b.n_tup_del from pg_class a, pg_stat_all_tables b where a.oid=b.relid and a.relkind = 'r'"
  
  #define FRONTEND
! #define PAGES_QUERY "select oid,reltuples,relpages from pg_class where oid=%i"
  #define FROZENOID_QUERY "select oid,age(datfrozenxid) from pg_database where datname = 'template1'"
  #define FROZENOID_QUERY2 "select oid,datname,age(datfrozenxid) from pg_database where datname!='template0'"
  
***************
*** 84,90 ****
  {
  	char	   *schema_name,
  			   *table_name;
! 	int			relfilenode,
  				reltuples,
  				relisshared,
  				relpages;
--- 84,90 ----
  {
  	char	   *schema_name,
  			   *table_name;
! 	int			relid,
  				reltuples,
  				relisshared,
  				relpages;
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

               http://www.postgresql.org/docs/faqs/FAQ.html

Reply via email to