I made the patch that improved the performance of replace_text(). The content of the patch is as follows:
I made the patch that improved the performance of replace_text().
The content of the patch is as follows:

(1)Create shortcut when subtext was not found.

(2)Stop using LEFT and RIGHT macro.
In LEFT and RIGHT macro, TEXTPOS is executed by the same content as
execution immediately before. The execution frequency of TEXTPOS can be
reduced by using text_substring instead of LEFT and RIGHT macro.

(3)Add appendStringInfoText, and use it instead of
appendStringInfoString.
There is an overhead of PG_TEXT_GET_STR when appendStringInfoString is
executed by text type. This can be reduced by appendStringInfoText.

(4)Reduce execution of TEXTDUP.

The effect of the patch that I measured is as follows:

- The Data for test was created by 'pgbench -i'.

- Test SQL:
 select replace(aid, '9', 'A') from accounts;

- Test results: Linux(CPU: Pentium III, Compiler option: -O2)
 original: 1.515s
 patched:  1.250s

Atsushi Ogawa

50wu/gpdb,0x0FFF/gpdb,greenplum-db/gpdb,randomtask1155/gpdb,tpostgres-projects/tPostgres,CraigHarris/gpdb,royc1/gpdb,janebeckman/gpdb,rvs/gpdb,0x0FFF/gpdb,0x0FFF/gpdb,lisakowen/gpdb,lintzc/gpdb,royc1/gpdb,arcivanov/postgres-xl,zaksoup/gpdb,yazun/postgres-xl,jmcatamney/gpdb,rvs/gpdb,lisakowen/gpdb,yazun/postgres-xl,janebeckman/gpdb,edespino/gpdb,Chibin/gpdb,postmind-net/postgres-xl,rubikloud/gpdb,rubikloud/gpdb,CraigHarris/gpdb,kmjungersen/PostgresXL,jmcatamney/gpdb,oberstet/postgres-xl,Postgres-XL/Postgres-XL,xuegang/gpdb,lpetrov-pivotal/gpdb,randomtask1155/gpdb,cjcjameson/gpdb,rubikloud/gpdb,foyzur/gpdb,janebeckman/gpdb,arcivanov/postgres-xl,jmcatamney/gpdb,Quikling/gpdb,lpetrov-pivotal/gpdb,xuegang/gpdb,jmcatamney/gpdb,greenplum-db/gpdb,ovr/postgres-xl,edespino/gpdb,chrishajas/gpdb,rvs/gpdb,yuanzhao/gpdb,rvs/gpdb,jmcatamney/gpdb,edespino/gpdb,cjcjameson/gpdb,royc1/gpdb,50wu/gpdb,zaksoup/gpdb,tangp3/gpdb,ashwinstar/gpdb,ovr/postgres-xl,atris/gpdb,Chibin/gpdb,ahachete/gpdb,lisakowen/gpdb,randomtask1155/gpdb,xinzweb/gpdb,ahachete/gpdb,chrishajas/gpdb,ahachete/gpdb,50wu/gpdb,edespino/gpdb,ashwinstar/gpdb,ashwinstar/gpdb,Quikling/gpdb,xinzweb/gpdb,randomtask1155/gpdb,pavanvd/postgres-xl,lisakowen/gpdb,royc1/gpdb,tpostgres-projects/tPostgres,royc1/gpdb,Postgres-XL/Postgres-XL,lisakowen/gpdb,yuanzhao/gpdb,postmind-net/postgres-xl,xinzweb/gpdb,zeroae/postgres-xl,tangp3/gpdb,lintzc/gpdb,snaga/postgres-xl,Quikling/gpdb,cjcjameson/gpdb,tangp3/gpdb,Quikling/gpdb,lisakowen/gpdb,lisakowen/gpdb,janebeckman/gpdb,xuegang/gpdb,tangp3/gpdb,chrishajas/gpdb,foyzur/gpdb,0x0FFF/gpdb,foyzur/gpdb,janebeckman/gpdb,ahachete/gpdb,yuanzhao/gpdb,Quikling/gpdb,xinzweb/gpdb,kaknikhil/gpdb,pavanvd/postgres-xl,jmcatamney/gpdb,Chibin/gpdb,jmcatamney/gpdb,ashwinstar/gpdb,techdragon/Postgres-XL,50wu/gpdb,kaknikhil/gpdb,CraigHarris/gpdb,Chibin/gpdb,atris/gpdb,rvs/gpdb,0x0FFF/gpdb,Quikling/gpdb,foyzur/gpdb,xuegang/gpdb,rvs/gpdb,ahachete/gpdb,oberstet/postgres-xl,yuanzhao/gpdb,edespino/gpdb,tangp3/gpdb,50wu/gpdb,tpostgres-projects/tPostgres,rubikloud/gpdb,kaknikhil/gpdb,kmjungersen/PostgresXL,greenplum-db/gpdb,ovr/postgres-xl,CraigHarris/gpdb,kaknikhil/gpdb,janebeckman/gpdb,techdragon/Postgres-XL,foyzur/gpdb,edespino/gpdb,edespino/gpdb,rubikloud/gpdb,kaknikhil/gpdb,zeroae/postgres-xl,atris/gpdb,adam8157/gpdb,atris/gpdb,pavanvd/postgres-xl,xuegang/gpdb,greenplum-db/gpdb,xuegang/gpdb,greenplum-db/gpdb,adam8157/gpdb,xuegang/gpdb,Chibin/gpdb,adam8157/gpdb,lisakowen/gpdb,cjcjameson/gpdb,adam8157/gpdb,kaknikhil/gpdb,lintzc/gpdb,cjcjameson/gpdb,chrishajas/gpdb,snaga/postgres-xl,Chibin/gpdb,rubikloud/gpdb,lpetrov-pivotal/gpdb,Quikling/gpdb,randomtask1155/gpdb,atris/gpdb,kaknikhil/gpdb,yazun/postgres-xl,arcivanov/postgres-xl,chrishajas/gpdb,lintzc/gpdb,snaga/postgres-xl,kmjungersen/PostgresXL,ovr/postgres-xl,50wu/gpdb,tangp3/gpdb,lpetrov-pivotal/gpdb,adam8157/gpdb,cjcjameson/gpdb,rvs/gpdb,arcivanov/postgres-xl,Chibin/gpdb,techdragon/Postgres-XL,postmind-net/postgres-xl,kaknikhil/gpdb,jmcatamney/gpdb,yuanzhao/gpdb,atris/gpdb,zeroae/postgres-xl,ovr/postgres-xl,CraigHarris/gpdb,chrishajas/gpdb,foyzur/gpdb,lintzc/gpdb,postmind-net/postgres-xl,lintzc/gpdb,rvs/gpdb,50wu/gpdb,CraigHarris/gpdb,yazun/postgres-xl,chrishajas/gpdb,rvs/gpdb,foyzur/gpdb,kaknikhil/gpdb,cjcjameson/gpdb,royc1/gpdb,greenplum-db/gpdb,kaknikhil/gpdb,adam8157/gpdb,snaga/postgres-xl,rubikloud/gpdb,Postgres-XL/Postgres-XL,0x0FFF/gpdb,0x0FFF/gpdb,zaksoup/gpdb,CraigHarris/gpdb,tangp3/gpdb,xuegang/gpdb,janebeckman/gpdb,arcivanov/postgres-xl,Quikling/gpdb,zaksoup/gpdb,zaksoup/gpdb,xinzweb/gpdb,50wu/gpdb,adam8157/gpdb,zeroae/postgres-xl,atris/gpdb,kmjungersen/PostgresXL,techdragon/Postgres-XL,oberstet/postgres-xl,cjcjameson/gpdb,ashwinstar/gpdb,lpetrov-pivotal/gpdb,edespino/gpdb,Quikling/gpdb,yuanzhao/gpdb,kmjungersen/PostgresXL,janebeckman/gpdb,postmind-net/postgres-xl,pavanvd/postgres-xl,Chibin/gpdb,yuanzhao/gpdb,lpetrov-pivotal/gpdb,yuanzhao/gpdb,lpetrov-pivotal/gpdb,ahachete/gpdb,tpostgres-projects/tPostgres,ashwinstar/gpdb,pavanvd/postgres-xl,royc1/gpdb,greenplum-db/gpdb,ashwinstar/gpdb,edespino/gpdb,cjcjameson/gpdb,janebeckman/gpdb,xuegang/gpdb,yuanzhao/gpdb,Postgres-XL/Postgres-XL,arcivanov/postgres-xl,Quikling/gpdb,oberstet/postgres-xl,lintzc/gpdb,snaga/postgres-xl,lintzc/gpdb,xinzweb/gpdb,royc1/gpdb,rvs/gpdb,chrishajas/gpdb,randomtask1155/gpdb,randomtask1155/gpdb,foyzur/gpdb,zeroae/postgres-xl,ahachete/gpdb,zaksoup/gpdb,atris/gpdb,oberstet/postgres-xl,cjcjameson/gpdb,Chibin/gpdb,ahachete/gpdb,randomtask1155/gpdb,yazun/postgres-xl,adam8157/gpdb,0x0FFF/gpdb,lpetrov-pivotal/gpdb,Chibin/gpdb,CraigHarris/gpdb,yuanzhao/gpdb,greenplum-db/gpdb,zaksoup/gpdb,techdragon/Postgres-XL,xinzweb/gpdb,xinzweb/gpdb,tangp3/gpdb,tpostgres-projects/tPostgres,CraigHarris/gpdb,edespino/gpdb,lintzc/gpdb,rubikloud/gpdb,Postgres-XL/Postgres-XL,janebeckman/gpdb,ashwinstar/gpdb,zaksoup/gpdb