>> Could you please elaborate why "Current usage 8000kB" can bigger than
>> "temp file limit 8kB"? I undertstand the point that temp files are
>> allocated by 8kB at once, but I don't understand why those numbers you
>> suggested could happen. Actually I tried with the modified patches and
>> got:
> 
>> test=# CREATE TEMPORARY TABLE resourcetemp1 AS SELECT 
>> generate_series(1,100000);
>> SELECT 100000
>> test=# SET temp_file_limit = 578;
>> SET
>> test=# SELECT count(*) FROM (select * FROM resourcetemp1  ORDER BY 1) AS a;
>> ERROR:  aborting due to exceeding temp file limit, current usage 576kB, 
>> requested size 8192kB, thus it will exceed temp file limit 578kB
> 
> You didn't show us how you computed those numbers, but I'm really
> dubious that FileWrite() has got any ability to produce numbers that
> are helpful.  Like Cedric, I think the write amount in any one call
> is usually going to be one block.

Here it is(fd.c).

        /*
         * If performing this write will increase the file size, then abort if 
it will
         * exceed temp_file_limit
         */
        if (temp_file_limit >= 0 && VfdCache[file].fdstate & FD_TEMPORARY)
        {
                if (VfdCache[file].seekPos + amount >= VfdCache[file].fileSize)
                {
                        increaseSize = true;
                        if ((temporary_files_size + (double)amount) / 1024.0 > 
(double)temp_file_limit)
                                ereport(ERROR,
                                                
(errcode(ERRCODE_QUERY_CANCELED),
                                                 errmsg("aborting due to 
exceeding temp file limit, current usage %dkB, requested size %dkB, thus it 
will exceed temp file limit %dkB",
                                                                
(int)(temporary_files_size/1024),
                                                                amount,
                                                                
temp_file_limit)));
                }
        }

I also attached the whole patch against fd.c at the point when Mark
proposed the changes.
--
Tatsuo Ishii
SRA OSS, Inc. Japan
English: http://www.sraoss.co.jp/index_en.php
Japanese: http://www.sraoss.co.jp

Attachment: fd.c.patch.gz
Description: Binary data

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to