Re: Australian timezone configure option
Bruce Momjian <pgman@candle.pha.pa.us>
From: Bruce Momjian <pgman@candle.pha.pa.us>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Chris Dunlop <chris@onthe.net.au>, pgsql-patches@postgresql.org
Date: 2001-06-12T15:18:29Z
Lists: pgsql-hackers
Attachments
- (unnamed) (text/plain)
> Bruce Momjian <pgman@candle.pha.pa.us> writes: > > OK, this patch makes Australian_timezones a GUC option. It can be set > > anytime in psql. The code uses a static variable to check if the GUC > > setting has changed and adjust the C struct accordingly. > > This is a horrid approach. What if you get an error partway through > scribbling on the static table? Then you've got inconsistent data. I have set the variable to -1 on entry so it will reload on failure, though it is only doing C lookups on a static table so it is hard to see how it would fail. > Nor do I much care for having to execute a check subroutine before any > use of the lookup table (quite aside from speed, are you sure it's being > called before *every* use of the table? how will you make sure that > people remember to call it when they add new routines that use the > table?). If you're going to scribble on the table, ISTM you should > drive that off an assignment-hook callback from the GUC stuff. But we don't have such hooks so I did it with as little code as possible. The table itself is 'static' so it is only called in this function. (The old patch had the static removed because I thought I was going to have to do this stuff in the guc files but now it is all in the same file.) > Besides which, you forgot to mark the control variable static... > so it doesn't actually reflect the state of the table. Fixed. I had that in an ealier version but forgot to add it when I moved it out to a separate function. > It would be a lot cleaner to extend the lookup table structure so that > you don't need to change the table contents to track the Aussie-rules > setting. Yes, when we do that we can remove the call and call it instead from the GUC setting. Here is a new version of the patch. I found I didn't need to clear the date cache. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026