text:
Home > UGS > FIU ETD > 1011
FIU Electronic Theses and Dissertations
Three Essays on the Microstructure of Exchange Traded Funds
Samique MarchFollow
Major/Program
First Advisor's Name
Suchismita Mishra
First Advisor's Committee Title
Second Advisor's Name
Robert Daigler
Third Advisor's Name
Abhijit Barua
Fourth Advisor's Name
Arun J. Prakash
Microstructure, ETF, liquidity, exchange traded funds
Exchange traded funds (ETFs) have increased significantly in popularity since they were first introduced in 1993. However, there is still much that is unknown about ETFs in the extant literature. This dissertation attempts to fill gaps in the ETF literature by using three related essays. In these three essays, we compare ETFs to closed ended mutual funds (CEFs) by decomposing the bid-ask spread into its three components; we look at the intraday shape of ETFs and compare it to the intraday shape of equities as well as examine the co-integration factor between ETFs on the London Stock Exchange and the New York Stock Exchange; we also examine the differences between leveraged ETFs and unleveraged ETFs by analyzing the impact of liquidity and volatility. These three essays are presented in Chapters 1, 2, and 3, respectively.
Chapter one uses the Huang and Stoll (1997) model to decompose the bid-ask spread in CEFs and ETFs for two distinct periods—a normal and a volatile period. We show a higher adverse selection component for CEFs than for ETFs without regard to volatility. However, both ETFs and CEFs increased in magnitude of the adverse selection component in the period of high volatility. Chapter two uses a mix of the Werner and Kleidon (1993) and the Hupperets and Menkveld (2002) methods to get the intraday shape of ETFs and analyze co-integration between London and New York trading. We find two different shapes for New York and London ETFs. There also appears to be evidence of co-integration in the overlapping two-hour trading period but not over the entire trading day for the two locations. The third chapter discusses the new class of ETFs called leveraged ETFs. We examine the liquidity and depth differences between unleveraged and leveraged ETFs at the aggregate level and when the leveraged ETFs are classified by the leveraged multiples of -3, -2, -1, 2, and 3, both for a normal and a volatile period. We find distinct differences between leveraged and unleveraged ETFs at the aggregate level, with leveraged ETFs having larger spreads than unleveraged ETFs. Furthermore, while both leveraged and unleveraged ETFs have larger spreads in high volatility, for the leveraged ETFs the change in magnitude is significantly larger than for the unleveraged ETFs. Among the multiples, the -2 leveraged ETF is the most pronounced in its liquidity characteristics, more so in volatile times.
March, Samique, "Three Essays on the Microstructure of Exchange Traded Funds" (2013). FIU Electronic Theses and Dissertations. 1011.
https://digitalcommons.fiu.edu/etd/1011
10.25148/etd.FI13121202
In Copyright. URI: http://rightsstatements.org/vocab/InC/1.0/
This Item is protected by copyright and/or related rights. You are free to use this Item in any way that is permitted by the copyright and related rights legislation that applies to your use. For other uses you need to obtain permission from the rights-holder(s).
FIU University Graduate School


As said in my 'Christmas Tag 2016' post, I'm really not one for making resolutions because I just don't keep to them and it seems pretty pointless for me. However, I have decided to think of a few things that I can change or do that aren't ridiculously difficult and don't really matter if I mess up on, but would be good if I did succeed in by the end of 2017 (that seems SOO far away right now..)! I just wanted to share these with you, in case you are the same as me and don't really stick to your resolutions (I mean come on, who does?!) as they might help inspire you for some easier-to-stick-to goals!
The first thing I would like to accomplish is pretty easy and to be honest, quite fun! (Well, it is for me at least...) As you might know, I enjoy reading quite a lot but I tend to have to push it aside for more important jobs now, since I am getting busier and it's kind of upsetting, because I love losing myself in a good book! So the first thing I want to do in 2017 is read 12 books. I'm currently part way through Dracula, so I'm not sure if I'll include that in my 12 books, because technically I've already started this year. But we will see!
The next thing is a little bigger than my previous goal and actually a lot more important too! I've never been skinny, and in all honesty I don't think I will be! None of my family would ever be size 0 models and I think there is just something that makes our metabolism a little slower. Although I know that I won't be skinny, I do want to lose some weight, or just be healthier in general! I want to lose around a stone, or maybe even more just so that I can start feeling and looking healthier. I have been on the contraceptive injection for a few months now, and that is also known for weight gain, which just pushes me to try even harder, since I know that if I don't do anything I will just keep on gaining weight. My car is another big problem, since I've had it I've not had to walk anywhere, I used to have to either walk to work, or to the bus stop which was a little more exercise. But now, I just don't and I can really tell the difference. So, I want to set a target and try to get more exercise and do more things that don't require driving in the year of 2017!
This one is a little bit of a weird one. I tend to be quite a friendly and helpful person, I tend to put other people before me and let them go first. One place I don't tend to do this as often though is on the road! Seriously, I get such road rage because people are all just so RUDE on the road. It's becoming really dangerous on the road because people are in such a rush to get places and it just creates such a domino effect. Someone pulls out on you, so you get angry and decide to penalize everyone else for that one rude person... and it just goes on and on! So one thing I am aiming to do, is to help out 1 person on the road each day, by letting them out, or letting them in front of me, so that at least some people benefit and the domino effect decreases a little bit. I'm not saying by me doing this that suddenly the roads are going to become pleasant and easy, but at least I'm helping out a little bit, and that itself makes me feel better.
I have another fun little thing that I would also like to complete in 2017. This one is more unknown and hasn't been featured on my blog (I'm looking to change that in the upcoming year) but I actually really enjoy crafts and one thing I'm learning in more depth is crochet. I've already completed a few projects, which I might share in a post, but I have started a Tetris crochet blanket and to be honest, it's been going on for quite a while! So I would like to finish that in 2017 and maybe make a few little extras to go with it.
That's it for my main goals! What are your resolutions for the new year? Do you make resolutions, and how long do you stick to them for?!


text:
Q: LTPA ChallengeHandler Javascript MFP8 I'm working on the new Platform MFP8 and I want to implement an LTPA Authentication in an hybrid application. Searching in the web I found a Swift implementation of LTPA ChallengeHandler (https://github.com/mfpdev/ldap-and-ltpa-sample/tree/master/LTPABasedSample). But, if I try to replicate the same behaviour in a JS challengeHandler, it doesn't work.
Below my challengeHandler implementation:
var UserLoginChallengeHandler = function() {
    var isChallenged = false;
    var securityCheckName = 'LTPA';
    var URL;
    var userLoginChallengeHandler = WL.Client.createSecurityCheckChallengeHandler(securityCheckName);

    document.getElementById("login").addEventListener("click", login);

    userLoginChallengeHandler.securityCheckName = securityCheckName;

    userLoginChallengeHandler.handleChallenge = function(challenge) {
        WL.Logger.debug("handleChallenge");
        showLoginDiv();
        isChallenged = true;
        URL = challenge.loginURL;
    };

    userLoginChallengeHandler.handleSuccess = function(data) {
        WL.Logger.debug("handleSuccess");
        isChallenged = false;
        showProtectedDiv();
    };

    userLoginChallengeHandler.handleFailure = function(error) {
        WL.Logger.debug("handleFailure: " + error.failure);
        isChallenged = false;
        if (error.failure !== null){
            alert(error.failure);
        } else {
            alert("Failed to login.");
        }
    };

    function login() {

        var basic = "Basic YWRtaW46YWRtaW4="; //base64 of admin:admin
        $.ajax({
          type: "POST",
          url: URL,
          headers: {
            "Authorization": basic
          },
          success: function(data, status, xhr){
            console.log(data);
            userLoginChallengeHandler.submitChallengeAnswer({});
          },
          error: function(jqXhr, status, error){
            console.log(error);
          }
        });
    }

    return userLoginChallengeHandler;

};

When I submit the request for plain-war application, the principal in the authorize method of LTPASecurityCheck results null.
Instead, if I execute the iOS example application, the principal is valued and the authentication occurs.
Have you any idea to resolve this strange behavior?
Thanks a lot,
Stefano

A: I think that the Swift sample is not sending POST request but GET. Have you tried to send it as GET?

redpajama_set_name: RedPajamaStackExchange


I am sure you all remember where the camp was located, but just in case, two maps are provided.
As you traveled the long gravel road (at least it was gravel when I was there) that led to camp, the first thing you passed on your right was the stables, with the barn, the corrals and open fields for the horses to graze. Not far away was the baseball field that was affectionately known as cowpie stadium.
Next came the camp gate, a stone's throw away from Sneak-a-Leak Creek. And then you went by Barney's cabin (caretaker's cabin) as we knew it when I was there. Continuing on you pass the camp mail box, then the office and into the parking lot. The parking area also substituted as the basketball courts where many a skins vs. shirts game was played.
Once in the parking lot you couldn't miss the large Club House that served as our dinning room and meeting place. A place filled with camp history. The Greens and Greys by year on the log wall that ringed the inside of the building and the Birch Bark logs hanging from the rafters with the names of campers, counselors and staff attending each year of camp, stretching back decades. This was the place to which we raced from the inspection grounds to be first in line at one of the doors, the place we ate those ?institutional meals? that almost tasted home-cooked because Joe and Louie knew how to make it so. This was the place where we played that game of PIG to see who scrapped the plates and cleaned the table. This was the place of Pillow Fights, Green and Grey Banquets, Skits, Chinese Toasts, and Final Banquets.
And how many campers ever had the thrill of ringing the camp bell that sat on top of the dining hall. To ring that bell for breakfast, lunch or dinner and know that hundreds of campers were thundering toward that great hall with one thought in mind?getting to that special place at the cabin table. It was a real thrill that not everyone got to experience. It was the Cook's choice, or sometimes even Ken and Ruby, to pick that special camper who got to ring that bell.
Outside the Club House was the Well House. A place to meet, a place to talk story, a place to wait your turn on box-hockey, tether ball, or a game of horse to try to double your take at the next candy day. Next to the well house was the Big Bell, a place to meet and sometimes carve your initials in logs that held the bell in place. You couldn't ring that bell, but sometimes, curious campers were known to have launched rocks into the insides of the bell, just hear its sound.
Behind the Club House was the Inspection Ground with the Flag Pole. A morning and evening assembly place that each camper dreaded if he had dirty hands, fingernails or ears, or, if he was not into doing his morning exercises! This was a place with a view, a panorama of Lake Charlevoix, the point of entry to Oyster Bay and to Junior Bay. It was also home to camp cook-outs and the Fourth of July cook -out.
On the other side of the Club House was Ken's Cabin, the Junior Section cabins, the tennis courts and of course, Junior Bay. For many years the Junior campers had their own beach and swimming area at Junior Bay.
If you were headed to the Senior Waterfront, or the Prep, Intermediate and Senior Section Cabins you had to pass by the Infirmary, the Quonset Hut (Bigwam) and the Handicraft building.
Moving further down the road you came to the Prep, Intermediate and Senior cabins. The Junior cabins were on the other side of the camp. The cabins, our home away from home for many weeks was located a stone's throw from the shoreline of Lake Charlevoix. In hindsight, some had spectacular views of the lake. Prime waterfront property in today's real estate parlance. Who knows what the square footage was inside the cabin, but they seemed to be big enough for 7 or 8 campers, plus a counselor. What was your choice? An upper or a lower bunk? Or did you like the dorm-style bed that was found in some cabins. Whatever your choice, you usually found a way to call it your own for four or eight weeks. I know that I personally carved my initials in the logs surrounding my bed in at least four different cabins. My trusty pocket knife or a horseshoe nail retrieved from the stables was all I needed to make my mark.
One of the most used areas of the camp, outside of the Club House, was the Senior Waterfront, home to instructional swims, sailing, and in later years canoeing. With its long dock, weathered boathouse and ?Blue Swimmer's? raft, the Senior Waterfront was visited daily by nearly all campers.
At the end of the road that lead past the Crafts building, the showers and the Prep, Intermediate and Senior sections was the Rifle Range, the Chapel and council fire area.


text:
Tvs With Dvd Players Built In 32 Inch
A television with a built-in DVD player is a great option for people who want a TV and DVD player in one device. The DVD player can be used to play DVDs that are stored in the TV's cabinet, or it can be used to play DVDs that are inserted into the TV from outside the cabinet. Some TVs with built-in DVD players also have the ability to connect to the Internet and stream movies and TV shows.
There are a number of TVs with built-in DVD players that are available in different sizes. The most popular size for a TV with a built-in DVD player is 32 inches. Some of the best TVs with DVD players built in are made by Samsung, Sony, and LG.
Samsung is a popular brand of TVs, and the company offers a number of TVs with DVD players built in. The Samsung UN32J5500AFXZA is a 32-inch TV that has a built-in DVD player. This TV has a number of features that make it a great option for people who want a TV with a built-in DVD player. The Samsung UN32J5500AFXZA has a 1080p resolution, which means that the image quality is very good. The TV also has a 120 Hz refresh rate, which helps to ensure that the image on the screen is smooth.
Sony is also a popular brand of TVs, and the company offers a number of TVs with DVD players built in. The Sony KDL32W600D is a 32-inch TV that has a built-in DVD player. This TV has a 720p resolution, which is not as good as the 1080p resolution offered by the Samsung UN32J5500AFXZA, but it is still a good resolution. The Sony KDL32W600D also has a 60 Hz refresh rate, which is not as good as the 120 Hz refresh rate offered by the Samsung UN32J5500AFXZA, but it is still good.
LG is another popular brand of TVs, and the company offers a number of TVs with DVD players built in. The LG 32LH500D is a 32-inch TV that has a built-in DVD player. This TV has a 720p resolution, which is not as good as the 1080p resolution offered by the Samsung UN32J5500AFXZA and the Sony KDL32W600D, but it is still a good resolution. The LG 32LH500D also has a 60 Hz refresh rate, which is not as good as the 120 Hz refresh rate offered by the Samsung UN32J5500AFXZA and the Sony KDL32W600D, but it is still good.
1 Can you buy TV with DVD player built in?
2 Does the Samsung smart TV have a built in DVD player?
3 Does Vizio make a TV DVD combo?
4 Do they make 32 inch TVs anymore?
5 Which TV DVD combo is best?
6 Are smart TVs compatible with DVD players?
7 Are DVD players being phased out?
See also Alice Through The Looking Glass Dvd
Can you buy TV with DVD player built in?
Can you buy a TV with a DVD player built in?
It depends on the TV. Some TVs have DVD players built in, while others do not. You can usually find TVs with DVD players built in at lower price points, but you may also find some TVs without DVD players built in that are more expensive.
If you are looking for a TV with a DVD player built in, it is important to consider your needs and preferences. Some people may prefer to have a standalone DVD player, while others may find it more convenient to have the DVD player built in to the TV.
It is also important to consider the other features that are important to you. For example, some people may prefer a TV with a larger screen size, while others may prefer a TV with a higher resolution.
Ultimately, the best way to determine whether or not you can buy a TV with a DVD player built in is to consult with a sales representative at your local electronics store.
Does the Samsung smart TV have a built in DVD player?
The Samsung smart TV has a built in DVD player. This means that you can watch DVDs on your TV without having to purchase an external DVD player. The Samsung smart TV has a variety of features that make it a great option for watching DVDs. For example, the Samsung smart TV has a high resolution screen that makes the image quality clear and crisp. In addition, the Samsung smart TV has a built in surround sound system that provides a great listening experience.
Does Vizio make a TV DVD combo?
Many people are wondering if Vizio makes a TV DVD combo. Unfortunately, at this time, Vizio does not make a TV DVD combo. However, the company does offer a wide range of televisions that come with built-in streaming capabilities, so you can access your favorite streaming content without needing a separate device.
If you're looking for a TV DVD combo, there are a number of other brands that offer this type of product. Samsung, for example, makes a number of TV DVD combos that are perfect for those who want a traditional entertainment experience. LG also offers a wide range of combo TVs, and you can find a number of great deals on these products if you shop around.
Ultimately, the best way to find the right TV DVD combo for your needs is to shop around and compare products. There are a number of great options available, so you're sure to find something that meets your needs and budget.
See also Make Phone Call From Computer Free
Do they make 32 inch TVs anymore?
This is a question that may have crossed your mind if you're in the market for a new television. The answer is yes, they do still make 32 inch TVs, but they may not be the best option if you're looking for a bigger screen.
Television manufacturers have been gradually phasing out 32 inch models in favor of larger sizes in recent years. This is likely due to the fact that larger TVs are becoming more affordable and there is more demand for them.
If you're specifically looking for a 32 inch TV, your best bet is to check online retailers or specialty stores. You may also find some deals on older models at discount stores. Just be sure to compare prices and read reviews before making a purchase.
Overall, 32 inch TVs are becoming increasingly difficult to find, so you may want to consider a larger size if you're open to it.
Which TV DVD combo is best?
There are many different TV DVD combos on the market, so it can be hard to decide which one is best for you. In this article, we will compare and contrast some of the most popular combos to help you make a decision.
The first combo we will look at is the Sony Bravia KDL-40W600B. This combo comes with a 40-inch LCD screen and a built-in DVD player. It is a great choice for people who want a large screen TV and don't want to clutter their room with multiple devices.
The next combo is the Samsung UN32J5500. This combo comes with a 32-inch LED screen and a built-in DVD player. This is a great choice for people who want a smaller TV or who want to save money by not having to buy a separate DVD player.
The third combo is the LG Electronics 32LN5100. This combo comes with a 32-inch LED screen and a built-in DVD player. This is a good choice for people who want a smaller TV and don't want to spend a lot of money.
The fourth combo is the Samsung UN55JU7500. This combo comes with a 55-inch LED screen and a built-in DVD player. This is a good choice for people who want a large TV and don't want to clutter their room with multiple devices.
The fifth combo is the Sony Bravia KDL-55W800B. This combo comes with a 55-inch LCD screen and a built-in DVD player. This is a great choice for people who want a large screen TV and don't want to clutter their room with multiple devices.
See also Best Desktop Computer With Ssd Drive
So, which TV DVD combo is best for you? It depends on your needs and preferences. All of the combos we listed are good choices, so it really comes down to what you are looking for.
Are smart TVs compatible with DVD players?
The short answer is yes, most smart TVs are compatible with DVD players. However, there are a few things to keep in mind.
First, check to make sure your DVD player is compatible with your smart TV. Not all models are compatible with every type of TV.
Second, make sure your TV has an HDMI port. This is the most common type of port used for connecting devices like DVD players.
If your TV and DVD player both have HDMI ports, it should be relatively easy to connect them. Just follow the instructions in your DVD player's manual.
If your TV doesn't have an HDMI port, you may be able to use a different type of port, such as a VGA port. However, you'll need to buy a special adapter to do this.
Finally, keep in mind that not all DVD players can be used with smart TVs. If you're not sure whether your DVD player is compatible, check the manual or contact the manufacturer.
Are DVD players being phased out?
It's a question that has been asked for years, and with the advent of streaming services like Netflix and Hulu, the answer may finally be yes.
DVD players have been around since the late 1990s, and for a time they were the primary way to watch movies and TV shows. But with the rise of streaming services, many people are now choosing to watch content online instead of on disc.
As a result, DVD player sales have been declining in recent years. In fact, according to a report from the market research firm NPD Group, DVD player sales have declined by more than 50% since their peak in 2004.
While DVD players are still being made, it's likely that they will eventually be phased out. Streaming services are becoming more and more popular, and with the rise of 4K TVs, there's no need for a DVD player anymore.
All-in-one Computer Windows 10 Small Smart Tv With Dvd Player Under Counter Radios Cd Players
Tags: built-in player This, choice people want, screen built-in player, This combo comes
Previous PostPrevious Hp Dvd Firmware Update Utility
Next PostNext Scooby Doo On Zombie Island Dvd

redpajama_set_name: RedPajamaCommonCrawl


Protesters angered by Iran's cratering economy confronted police officers in front of parliament on Monday, with security forces firing tear gas at them, according to online videos, the first such confrontation after similar demonstrations rocked the country at the start of the year.
Fears about the impact of the US sanctions that will start to be reinstated in August and possibly trigger the collapse of the nuclear deal has led to the rial falling to a record low against the dollar on the unofficial foreign exchange market.
A dollar is currently worth as much as 90,000 rials, compared with 65,000 rials just before Mr Trump's announcement and 42,890 at the end of 2017.
The currency's fall also prompted traders at two shopping centres in Tehran that specialise in mobile phones to go on strike in protest on Sunday.
However, those protests largely struck Iran's provinces as opposed to Tehran itself . Analysts believe hard-liners likely encouraged the first protest that took place in Mashhad to weaken the administration of President Hassan Rouhani, a relative moderate cleric within Iran's politics. The protests then spiraled out of control, with people openly criticizing both Rouhani and Supreme Leader Ayatollah Ali Khamenei.
Needless to say, an overtly IRGC-controlled government would not be a pleasant prospect. There are few outcomes in Iran that would be worse than the present status quo but that would be one of those few, although the IRGC already has de facto control of Iranian policy and the economy. However, an open seizure of government, even if not a dramatic change in operational reality, would be the kind of system shock that could quickly backfire. A soft coup of this type may get out of control very quickly, and could not only threaten the mullahs but the IRGC itself. The Green Revolution got started by an incompetently rigged presidential election in 2009 and looked as though it would overthrow the regime, at least until the Obama administration legitimized the election outcome.
For the moment, though, this is just one massive protest. If there is to be any revolution, the dissenters will have to maintain this energy and pick up a lot more supporters. If they succeed at that, it might not matter who started it; it will only matter whose end it brings.


This month bestows so much light and spirituality upon a person's heart and soul that others can see it in their appearance as well. Others can understand based on their speaking and manners that they have become more enlightened: advanced in spirituality. True servants of God are like that.
Imam [Khomeini] was more enlightened spiritually after Ramadan. Key is that we manage to go through the path towards God during the month of Ramadan; and it is possible. Sometimes when I visited Imam Khomeini (R.A.), after the month of Ramadan, I could see that he had changed; he was more enlightened: his manners, his speaking, looking, movements and remarks were different than before that of Ramadan.
The month of Ramadan is as such for a virtuous person. This month bestows so much light and spirituality upon a person's heart and soul that others can see it in their appearance as well. Others can understand based on their speaking and manners that they have become more enlightened: advanced in spirituality. True servants of God are like that. We should make the most of this great opportunity.
The month of Ramadan is a manifestation of worshiping God: it is a lighted path toward piety; it is a cause for forgiveness of sins; it is a cause for the enlightenment of the hearts. Ramadan is a month when the Almighty God invites His servants to a feast, and they become closer to the Almighty God.
The month of Ramadan is the month of a divine banquet. Entrance into the arena of the divine banquet requires some preparedness. We should prepare the ground for this in ourselves.
This is easier for you dear youth than for us. With their pure and sincere hearts and without the impurities that emerge in individuals over the course of time, youth can be more prepared.
Next articleWhy is the month of Ramadan superior to other months?


text:
Battle of Manila Bay
Commodore George Dewey, Commander, Asiatic Station, to secretary of the Navy John D. Long, 4/9/1898
Commodore George Dewey, Commander, Asiatic Station, to secretary of the Navy John D. Long
HongKong, April 9, 1898.
Secretary of the Navy, Washington:
I have purchased the British steamer Zafiro, for supplies, for £18,000 sterling. I will arm, equip, and man vessel immediately.1
Source Note Print: Report of the Bureau of Navigation, 1898, p. 66.
Footnote 1: The Zafiro was purchased under orders from Secretary Long to act as a supply ship for the Asiatic Squadron. See: Long to Dewey, 5 April 1898.
Pre-War Planning
Destruction of the Maine
Naval War Board
Naval Intelligence
Coastal Defense
Naval Operations in the Caribbean
Naval Militia
Rear Admiral Francis M. Ramsay, Chief of the Bureau of Navigation, to Commander George Dewey, 6/19/1896
Assistant Secretary of the Navy Theodore Roosevelt to Senator William Eaton Chandler (New Hampshire), 9/29/1897
More Documents (86)
Senator Redfield Proctor of Vermont to Commodore George Dewey, 10/16/1897
Rear Admiral Frederick V. McNair, Commander, Asiatic Station, to Commodore George Dewey, 12/31/1897
Commodore George Dewey, Commander, Asiatic Station, to George Goodwin Dewey, 1/4/1898
Commodore George Dewey, Commander, Asiatic Station, to George Goodwin Dewey, 1/23/1898
Commodore Arent S.Crowninshield, Chief of the Bureau of Navigation, to Commodore George Dewey, Commander, Asiatic Station, 1/27/1898
Commander Asa Walker to Secretary of the Navy John D. Long, 2/12/1898
Commodore George Dewey, Commander, Asiatic Station, to United States Consul at Manila Oscar F. Williams, 2/17/1898
Assistant Secretary of the Navy Theodore Roosevelt to Commodore George Dewey, Commander, Asiatic Station, 2/26/1898
Secretary of the Navy John D. Long to Commodore George Dewey, Commander, Asiatic Station, 2/26/1898
Commodore George Dewey, Commander, Asiatic Station, to Secretary of the Navy John D. Long, 2/27/1898
Ensign Harry H. Caldwell to United States Consul at Manila Oscar F. Williams, 3/3/1898
Secretary of the Navy John D. Long to Rear Admiral William A. Kirkland, Commandant, Mare Island Navy Yard, 3/4/1898
Secretary of the Navy John D. Long to Commodore George Dewey, Commander, Asiatic Station, 3/4/1898
United States Consul at Manila Oscar F. Williams to Commodore George Dewey, Commander, Asiatic Station, 3/11/1898
Commodore Arent S. Crowninshield, Chief of the Bureau of Navigation, to Secretary of the Navy John D. Long, 3/11/1898
Commander George M. Book to Secretary of the Navy John D. Long, 3/19/1898
Rear Admiral Joseph N. Miller, Commander, Pacific Station, to Secretary of the Navy John D. Long, 3/24/1898
United States Consul at Singapore E. Spencer Pratt to Assistant Secretary of State William R. Day, 4/4/1898
Commodore George Dewey, Commander, Asiatic Station, to Commander Oscar W. Farenholt, 4/9/1898
Captain Nehemiah M. Dyer to Secretary of the Navy John D. Long, 4/11/1898
Basilio Agustin y Dávila, Governor General of the Philippines, 4/23/1898
Governor General of Hong Kong Wilsone Black to Commodore George Dewey, Commander, Asiatic Station, 4/23/1898
Commodore George Dewey, Commander, Asiatic Station, to Governor General at Hong Kong Wilsone Black, 4/24/1898
Lieutenant Humes H. Whittlesey to Secretary of the Navy John D. Long, 4/24/1898
Report of British Merchant Captain A.W. Robbins, 4/30/1898
Secretary of the Navy John D. Long to Agnes Pierce Long, 10/9/1898
Samuel C. Hudwell to Captain Henry A. Baldridge, 8/22/1940
Admiral Patricio Montojo y Pasarón to Minister of the Royal Spanish Navy Segismundo Bermejo y Merelo, 4/30/1898
Admiral Patricio Montojo y Pasarón (Royal Spanish Navy) Report of the Battle of Cavite, 5/1/1898
Basilio Agustin y Dávila, Governor General of the Philippines, to the Government of Spain, 5/1/1898
Lieutenant Commander Frederic Singer to Commander Joseph B. Coghlan, 5/1/1898
Medical Inspector Abel F. Price to Captain Charles V. Gridley, 5/1/1898
Log of the Petrel, 5/1/1898
Commodore George Dewey, Commander, Asiatic Squadron, to Secretary of the Navy John D. Long, 5/1/1898
Lieutenant Edward M. Hughes to Commander Edward P. Wood, 5/2/1898
Captain William P. Biddle , United States Marine Corps, to Captain Charles V. Gridley, 5/2/1898
Captain Frank Wildes to Commodore George Dewey, Commander, Asiatic Squadron, 5/3/1898
Captain Daniel E. Hodgson, Revenue Cutter Service, to Commodore George Dewey, Commander, Asiatic Squadron, 5/3/1898
Lieutenant Commander George P. Colvocoresses to Commander Asa Walker, 5/3/1898
Lieutenant Commander John B. Briggs to Captain Nehemia M. Dyer, 5/3/1898
Commander Edward P. Wood to Commodore George Dewey, Commander, Asiatic Squadron, 5/4/1898
United States Consul at Manila Oscar F. Williams to Assistant Secretary of State William R. Day, 5/4/1898
Assistant Secretary of the Navy Theodore Roosevelt to William Wingate Sewall, 5/4/1898
Captain Joseph B. Coghlan to Commodore George Dewey, Commander, Asiatic Squadron, 5/4/1898
Captain Nehemiah M. Dyer to Commodore George Dewey, Commander, Asiatic Squadron, 5/4/1898
Commodore George Dewey, Commander, Asiatic Squadron, to George Goodwin Dewey, 5/5/1898
Secretary of the Navy John D. Long to Commodore George Dewey, Commander, Asiatic Squadron, 5/7/1898
Rear Admiral George Dewey, Commander, Asiatic Squadron, to Secretary of the Navy John D. Long, 5/10/1898
Commander Edward P. Wood to Rear Admiral George Dewey, Commander, Asiatic Squadron, 6/26/1898
Admiral Patricio Montojo y Pasarón to Rear Admiral George Dewey, Commander, Asiatic Squadron, 9/28/1898
Rear Admiral Henry V. Butler, Jr., Commandant, Washington Navy Yard, Memorandum to Bureau of Navigation, 9/29/1930
Blockade of Northern Cuba
Telegraphy and Cable Cutting
Battle at Punta de la Colorados
Rescue of the Winslow
Bombardment of San Juan
Flying Squadron and the Search for the Spanish Fleet
Scuttling the Merrimac
Naval Operations at Santiago de Cuba
Naval Operations Guantanamo
Capture of Guam
Convoy and Landings at Daiquiri
Blockade of Puerto Rico
Joint Operations Santiago de Cuba
Blockade of Southern Cuba
Battle of Santiago Bay
Eastern Squadron
Blockade and Siege of Manila
Joint Operations Puerto Rico
Naval Operations Manzanillo
Naval Medicine
Command Diaries
Squadron Bulletins
Asiatic Squadron, Asiatic Station, Secretary Of The Navy, Zafiro, John D Long, George Dewey
Steam Power, Logistics
Additional Resources for Battle of Manila Bay
List of Ships and Commanders
American Ships and Commanders
Spanish Ships and Commanders


text:
#ifndef PRIMNODES_H
#define PRIMNODES_H

#include "access/attnum.h"
#include "nodes/pg_list.h"
#include "nodes/params.h"  /* For ParamListInfoData */
#include "cdb/cdbpathlocus.h" /* For CdbLocusType */

/* ----------------------------------------------------------------
 *						node definitions
 * ----------------------------------------------------------------
 */

/*
 * Alias -
 *	  specifies an alias for a range variable; the alias might also
 *	  specify renaming of columns within the table.
 *
 * Note: colnames is a list of Value nodes (always strings).  In Alias structs
 * associated with RTEs, there may be entries corresponding to dropped
 * columns; these are normally empty strings ("").	See parsenodes.h for info.
 */
typedef struct Alias
{
	NodeTag		type;
	char	   *aliasname;		/* aliased rel name (never qualified) */
	List	   *colnames;		/* optional list of column aliases */
} Alias;

typedef enum InhOption
{
	INH_NO,						/* Do NOT scan child tables */
	INH_YES,					/* DO scan child tables */
	INH_DEFAULT					/* Use current SQL_inheritance option */
} InhOption;

/* What to do at commit time for temporary relations */
typedef enum OnCommitAction
{
	ONCOMMIT_NOOP,				/* No ON COMMIT clause (do nothing) */
	ONCOMMIT_PRESERVE_ROWS,		/* ON COMMIT PRESERVE ROWS (do nothing) */
	ONCOMMIT_DELETE_ROWS,		/* ON COMMIT DELETE ROWS */
	ONCOMMIT_DROP				/* ON COMMIT DROP */
} OnCommitAction;

/*
 * RangeVar - range variable, used in FROM clauses
 *
 * Also used to represent table names in utility statements; there, the alias
 * field is not used, and inhOpt shows whether to apply the operation
 * recursively to child tables.  In some contexts it is also useful to carry
 * a TEMP table indication here.
 */
typedef struct RangeVar
{
	NodeTag		type;
	char	   *catalogname;	/* the catalog (database) name, or NULL */
	char	   *schemaname;		/* the schema name, or NULL */
	char	   *relname;		/* the relation/sequence name */
	InhOption	inhOpt;			/* expand rel by inheritance? recursively act
								 * on children? */
	bool		istemp;			/* is this a temp relation/sequence? */
	Alias	   *alias;			/* table alias & optional column aliases */
	int			location;		/* token location, or -1 if unknown */
} RangeVar;

typedef struct TableOidInfo
{
	Oid         relOid;			/* If the heap is (re-)created, create  with this relOid */
	Oid         comptypeOid;
	Oid		    toastOid;		/* if toast table needed, use this for the relOid of the toast */
	Oid		    toastIndexOid;	/* if toast table needed, use this for the relOid of the index */
	Oid			toastComptypeOid;
	Oid		    aosegOid;		/* if ao segment table needed, use this for the relOid of the aoseg table */
	Oid		    aosegIndexOid;	/* if ao segment table needed, use this for the relOid of the aoseg index */
	Oid			aosegComptypeOid;
	Oid		    aoblkdirOid;		/* if ao blkdir table needed, use this for the relOid of the aoblkdir table */
	Oid		    aoblkdirIndexOid;	/* if ao blkdir table needed, use this for the relOid of the aoblkdir index */
	Oid			aoblkdirComptypeOid;
} TableOidInfo;

/*
 * IntoClause - target information for SELECT INTO and CREATE TABLE AS
 */
typedef struct IntoClause
{
	NodeTag		type;

	RangeVar   *rel;			/* target relation name */
	List	   *colNames;		/* column names to assign, or NIL */
	List	   *options;		/* options from WITH clause */
	OnCommitAction onCommit;	/* what do we do at COMMIT? */
	char	   *tableSpaceName; /* table space to use, or NULL */

	/* MPP */
	TableOidInfo oidInfo;
} IntoClause;

/* ----------------------------------------------------------------
 *					node types for executable expressions
 * ----------------------------------------------------------------
 */

/*
 * Expr - generic superclass for executable-expression nodes
 *
 * All node types that are used in executable expression trees should derive
 * from Expr (that is, have Expr as their first field).  Since Expr only
 * contains NodeTag, this is a formality, but it is an easy form of
 * documentation.  See also the ExprState node types in execnodes.h.
 */
typedef struct Expr
{
	NodeTag		type;
} Expr;

/*
 * Var - expression node representing a variable (ie, a table column)
 *
 * Note: during parsing/planning, varnoold/varoattno are always just copies
 * of varno/varattno.  At the tail end of planning, Var nodes appearing in
 * upper-level plan nodes are reassigned to point to the outputs of their
 * subplans; for example, in a join node varno becomes INNER or OUTER and
 * varattno becomes the index of the proper element of that subplan's target
 * list.  But varnoold/varoattno continue to hold the original values.
 * The code doesn't really need varnoold/varoattno, but they are very useful
 * for debugging and interpreting completed plans, so we keep them around.
 */
#define    INNER		65000
#define    OUTER		65001

#define    PRS2_OLD_VARNO			1
#define    PRS2_NEW_VARNO			2

typedef struct Var
{
	Expr		xpr;
	Index		varno;			/* index of this var's relation in the range
								 * table (could also be INNER or OUTER) */
	AttrNumber	varattno;		/* attribute number of this var, or zero for
								 * all */
	Oid			vartype;		/* pg_type OID for the type of this var */
	int32		vartypmod;		/* pg_attribute typmod value */
	Index		varlevelsup;	/* for subquery variables referencing outer
								 * relations; 0 in a normal var, >0 means N
								 * levels up */
	Index		varnoold;		/* original value of varno, for debugging */
	AttrNumber	varoattno;		/* original value of varattno */
	int			location;		/* token location, or -1 if unknown */
} Var;

/*
 * Const
 */
typedef struct Const
{
	Expr		xpr;
	Oid			consttype;		/* pg_type OID of the constant's datatype */
	int32		consttypmod;	/* typmod value, if any */
	int			constlen;		/* typlen of the constant's datatype */
	Datum		constvalue;		/* the constant's value */
	bool		constisnull;	/* whether the constant is null (if true,
								 * constvalue is undefined) */
	bool		constbyval;		/* whether this datatype is passed by value.
								 * If true, then all the information is stored
								 * in the Datum. If false, then the Datum
								 * contains a pointer to the information. */
	int			location;		/* token location, or -1 if unknown */
} Const;

/* ----------------
 * Param
 *		paramkind - specifies the kind of parameter. The possible values
 *		for this field are:
 *
 *		PARAM_EXTERN:  The parameter value is supplied from outside the plan.
 *				Such parameters are numbered from 1 to n.
 *
 *		PARAM_EXEC:  The parameter is an internal executor parameter, used
 *				for passing values into and out of sub-queries.
 *				For historical reasons, such parameters are numbered from 0.
 *				These numbers are independent of PARAM_EXTERN numbers.
 *
 *		PARAM_SUBLINK:	The parameter represents an output column of a SubLink
 *				node's sub-select.  The column number is contained in the
 *				`paramid' field.  (This type of Param is converted to
 *				PARAM_EXEC during planning.)
 *
 * Note: currently, paramtypmod is valid for PARAM_SUBLINK Params, and for
 * PARAM_EXEC Params generated from them; it is always -1 for PARAM_EXTERN
 * params, since the APIs that supply values for such parameters don't carry
 * any typmod info.
 * ----------------
 */
typedef enum ParamKind
{
	PARAM_EXTERN,
	PARAM_EXEC,
	PARAM_EXEC_REMOTE, /* MPP ???? */
	PARAM_SUBLINK
} ParamKind;

typedef struct Param
{
	Expr		xpr;
	ParamKind	paramkind;		/* kind of parameter. See above */
	int			paramid;		/* numeric ID for parameter */
	Oid			paramtype;		/* pg_type OID of parameter's datatype */
	int32		paramtypmod;	/* typmod value, if known */
	int			location;		/* token location, or -1 if unknown */
} Param;

/* AggStage enumeration indicates how the executor should handle an
 * Aggref node.
 */
typedef enum AggStage
{
	AGGSTAGE_NORMAL = 0,
	AGGSTAGE_PARTIAL, /* First (lower, earlier) stage of 2-stage aggregation. */
	AGGSTAGE_INTERMEDIATE, /* The intermediate stage between AGGSTAGE_PARTIAL and
							* AGGSTAGE_FINAL that handles the higher aggregation
							* level in a (partial) ROLLUP grouping extension
							* query.
							*/
	AGGSTAGE_FINAL /* Second (upper, later) stage of 2-stage aggregation. */
} AggStage;

/*
 * AggOrder describes ordering information for ordered aggregates
 */
typedef struct AggOrder
{
    Expr        xpr;
    bool        sortImplicit;   /* Implict or explicit ordering? */
    List       *sortTargets;    /* Targetlist for order by clause */
    List       *sortClause;     /* Sort clause for the aggregate */
} AggOrder;

/*
 * Aggref
 */
typedef struct Aggref
{
	Expr		xpr;
	Oid			aggfnoid;		/* pg_proc Oid of the aggregate */
	Oid			aggtype;		/* type Oid of result of the aggregate */
	List	   *args;			/* arguments to the aggregate */
	Index		agglevelsup;	/* > 0 if agg belongs to outer query */
	bool		aggstar;		/* TRUE if argument list was really '*' */
	bool		aggdistinct;	/* TRUE if it's agg(DISTINCT ...) */
	AggStage	aggstage;		/* MPP: 2-stage? If so, which stage */
    AggOrder   *aggorder;       /* Ordered aggregate definition */
	int			location;		/* token location, or -1 if unknown */
} Aggref;

/*
 * Grouping: describe the hidden GROUPING column for grouping extensions.
 *
 * Defined for making it easily to distinguish this column with others.
 *
 * Used with GroupingFunc to distinguish 'null' values that are created
 * through grouping with those that are in the raw data. See also GroupingFunc
 * for more details.
 */
typedef struct Grouping
{
	Expr        xpr;
} Grouping;

/*
 * GroupId -
 *    representation of the hidden GROUP_ID column for grouping extensions.
 *
 * Defined to make it easy to distinguish this column from others.
 *
 * This is used to determine whether output tuples are coming from
 * duplicate grouping sets. For example, a table
 *
 *    test (a integer, b integer)
 *
 * has two rows:
 *
 *       (1,2), (1,2).
 *
 * Consider a rollup clause "rollup(a),a", which contains a grouping
 * set (a) twice. Therefore, the query
 *
 *    select a,sum(b),group_id() from test group by rollup(a),a;
 *
 * returns two rows:
 *
 *    1,4,0
 *    1,4,1
 *
 * The GROUP_ID value 0 indicates this tuple is from the grouping set (a).
 * The value 1 indicates this tuple is from the first duplicate grouping set of
 * (a).
 *
 * This query can be also re-written to the following:
 *
 *    select a,avg(b),0 from test group by a
 *      union all
 *    select a,avg(b),1 from test group by a;
 */
typedef struct GroupId
{
	Expr      xpr;
} GroupId;

/* WinStage enumeration indicates what stage of the evaluation of a
 * window function is expressed by a WindowRef.
 */
typedef enum WinStage
{
	WINSTAGE_IMMEDIATE = 0, /* Evaluate window function. */
	WINSTAGE_PRELIMINARY, /* Evaluate preliminary function. */
	WINSTAGE_ROWKEY /* WINSTAGE_IMMEDIATE for row key generation. */
} WinStage;

/*
 * WindowRef: describes a window function call
 *
 * In a query tree, a WindowRef corresponds to a SQL window function
 * call.  In a plan tree, a WindowRef is an expression the corresponds
 * to some or all of the calculation of the window function result.
 *
 */
typedef struct WindowRef
{
	Expr		xpr;
	Oid			winfnoid;		/* pg_proc Oid of the window function */
	Oid			restype;		/* type Oid of result of the window function */
	List	   *args;			/* arguments */
	Index		winlevelsup;	/* > 0 if win belongs to outer query  */
	bool		windistinct;	/* TRUE if it's agg(DISTINCT ...) */
	Index		winspec;		/* index into Query window clause */

	/* Following fields are significant only in a Plan tree. */
	Index		winindex;		/* RefInfo index during planning. */
	WinStage	winstage;		/* Stage of execution. */
	Index		winlevel;		/* Position of corresponding WindowKey in
								 * the Window node. */
	int			location;		/* token location, or -1 if unknown */
} WindowRef;

/* ----------------
 *	ArrayRef: describes an array subscripting operation
 *
 * An ArrayRef can describe fetching a single element from an array,
 * fetching a subarray (array slice), storing a single element into
 * an array, or storing a slice.  The "store" cases work with an
 * initial array value and a source value that is inserted into the
 * appropriate part of the array; the result of the operation is an
 * entire new modified array value.
 *
 * If reflowerindexpr = NIL, then we are fetching or storing a single array
 * element at the subscripts given by refupperindexpr.	Otherwise we are
 * fetching or storing an array slice, that is a rectangular subarray
 * with lower and upper bounds given by the index expressions.
 * reflowerindexpr must be the same length as refupperindexpr when it
 * is not NIL.
 *
 * Note: the result datatype is the element type when fetching a single
 * element; but it is the array type when doing subarray fetch or either
 * type of store.
 * ----------------
 */
typedef struct ArrayRef
{
	Expr		xpr;
	Oid			refrestype;		/* type of the result of the ArrayRef
								 * operation */
	Oid			refarraytype;	/* type of the array proper */
	Oid			refelemtype;	/* type of the array elements */
	int32		reftypmod;		/* typmod of the array (and elements too) */
	List	   *refupperindexpr;/* expressions that evaluate to upper array
								 * indexes */
	List	   *reflowerindexpr;/* expressions that evaluate to lower array
								 * indexes */
	Expr	   *refexpr;		/* the expression that evaluates to an array
								 * value */
	Expr	   *refassgnexpr;	/* expression for the source value, or NULL if
								 * fetch */
} ArrayRef;

/*
 * CoercionContext - distinguishes the allowed set of type casts
 *
 * NB: ordering of the alternatives is significant; later (larger) values
 * allow more casts than earlier ones.
 */
typedef enum CoercionContext
{
	COERCION_IMPLICIT,			/* coercion in context of expression */
	COERCION_ASSIGNMENT,		/* coercion in context of assignment */
	COERCION_EXPLICIT			/* explicit cast operation */
} CoercionContext;

/*
 * CoercionForm - information showing how to display a function-call node
 */
typedef enum CoercionForm
{
	COERCE_EXPLICIT_CALL,		/* display as a function call */
	COERCE_EXPLICIT_CAST,		/* display as an explicit cast */
	COERCE_IMPLICIT_CAST,		/* implicit cast, so hide it */
	COERCE_DONTCARE				/* special case for planner */
} CoercionForm;

/*
 * FuncExpr - expression node for a function call
 */
typedef struct FuncExpr
{
	Expr		xpr;
	Oid			funcid;			/* PG_PROC OID of the function */
	Oid			funcresulttype; /* PG_TYPE OID of result value */
	bool		funcretset;		/* true if function returns set */
	CoercionForm funcformat;	/* how to display this function call */
	List	   *args;			/* arguments to the function */
	int			location;		/* token location, or -1 if unknown */
	bool        is_tablefunc;   /* Is a TableFunction reference */
} FuncExpr;

/*
 * OpExpr - expression node for an operator invocation
 *
 * Semantically, this is essentially the same as a function call.
 *
 * Note that opfuncid is not necessarily filled in immediately on creation
 * of the node.  The planner makes sure it is valid before passing the node
 * tree to the executor, but during parsing/planning opfuncid can be 0.
 */
typedef struct OpExpr
{
	Expr		xpr;
	Oid			opno;			/* PG_OPERATOR OID of the operator */
	Oid			opfuncid;		/* PG_PROC OID of underlying function */
	Oid			opresulttype;	/* PG_TYPE OID of result value */
	bool		opretset;		/* true if operator returns set */
	List	   *args;			/* arguments to the operator (1 or 2) */
	int			location;		/* token location, or -1 if unknown */
} OpExpr;

/*
 * DistinctExpr - expression node for "x IS DISTINCT FROM y"
 *
 * Except for the nodetag, this is represented identically to an OpExpr
 * referencing the "=" operator for x and y.
 * We use "=", not the more obvious "<>", because more datatypes have "="
 * than "<>".  This means the executor must invert the operator result.
 * Note that the operator function won't be called at all if either input
 * is NULL, since then the result can be determined directly.
 */
typedef OpExpr DistinctExpr;

/*
 * ScalarArrayOpExpr - expression node for "scalar op ANY/ALL (array)"
 *
 * The operator must yield boolean.  It is applied to the left operand
 * and each element of the righthand array, and the results are combined
 * with OR or AND (for ANY or ALL respectively).  The node representation
 * is almost the same as for the underlying operator, but we need a useOr
 * flag to remember whether it's ANY or ALL, and we don't have to store
 * the result type because it must be boolean.
 */
typedef struct ScalarArrayOpExpr
{
	Expr		xpr;
	Oid			opno;			/* PG_OPERATOR OID of the operator */
	Oid			opfuncid;		/* PG_PROC OID of underlying function */
	bool		useOr;			/* true for ANY, false for ALL */
	List	   *args;			/* the scalar and array operands */
	int			location;		/* token location, or -1 if unknown */
} ScalarArrayOpExpr;

/*
 * BoolExpr - expression node for the basic Boolean operators AND, OR, NOT
 *
 * Notice the arguments are given as a List.  For NOT, of course the list
 * must always have exactly one element.  For AND and OR, the executor can
 * handle any number of arguments.	The parser generally treats AND and OR
 * as binary and so it typically only produces two-element lists, but the
 * optimizer will flatten trees of AND and OR nodes to produce longer lists
 * when possible.  There are also a few special cases where more arguments
 * can appear before optimization.
 */
typedef enum BoolExprType
{
	AND_EXPR, OR_EXPR, NOT_EXPR
} BoolExprType;

typedef struct BoolExpr
{
	Expr		xpr;
	BoolExprType boolop;
	List	   *args;			/* arguments to this expression */
	int			location;		/* token location, or -1 if unknown */
} BoolExpr;

/*
 * TableValueExpr - a "TABLE( <subquery> )" expression indicating a subquery
 * expression that is passed as a value to a function.
 *
 * This is <table value constructor by query> within the SQL Standard
 */
typedef struct TableValueExpr
{
	NodeTag     type;
	Node       *subquery;
	int         location;
} TableValueExpr;

/*
 * SubLink
 *
 * A SubLink represents a subselect appearing in an expression, and in some
 * cases also the combining operator(s) just above it.	The subLinkType
 * indicates the form of the expression represented:
 *	EXISTS_SUBLINK		EXISTS(SELECT ...)
 *	ALL_SUBLINK			(lefthand) op ALL (SELECT ...)
 *	ANY_SUBLINK			(lefthand) op ANY (SELECT ...)
 *	ROWCOMPARE_SUBLINK	(lefthand) op (SELECT ...)
 *	EXPR_SUBLINK		(SELECT with single targetlist item ...)
 *	ARRAY_SUBLINK		ARRAY(SELECT with single targetlist item ...)
 *	CTE_SUBLINK			WITH query (never actually part of an expression)
 * For ALL, ANY, and ROWCOMPARE, the lefthand is a list of expressions of the
 * same length as the subselect's targetlist.  ROWCOMPARE will *always* have
 * a list with more than one entry; if the subselect has just one target
 * then the parser will create an EXPR_SUBLINK instead (and any operator
 * above the subselect will be represented separately).  Note that both
 * ROWCOMPARE and EXPR require the subselect to deliver only one row.
 * ALL, ANY, and ROWCOMPARE require the combining operators to deliver boolean
 * results.  ALL and ANY combine the per-row results using AND and OR
 * semantics respectively.
 * ARRAY requires just one target column, and creates an array of the target
 * column's type using any number of rows resulting from the subselect.
 *
 * SubLink is classed as an Expr node, but it is not actually executable;
 * it must be replaced in the expression tree by a SubPlan node during
 * planning.
 *
 * NOTE: in the raw output of gram.y, testexpr contains just the raw form
 * of the lefthand expression (if any), and operName is the String name of
 * the combining operator.	Also, subselect is a raw parsetree.  During parse
 * analysis, the parser transforms testexpr into a complete boolean expression
 * that compares the lefthand value(s) to PARAM_SUBLINK nodes representing the
 * output columns of the subselect.  And subselect is transformed to a Query.
 * This is the representation seen in saved rules and in the rewriter.
 *
 * In EXISTS, EXPR, and ARRAY SubLinks, testexpr and operName are unused and
 * are always null.
 */
typedef enum SubLinkType
{
	EXISTS_SUBLINK,
	ALL_SUBLINK,
	ANY_SUBLINK,
	ROWCOMPARE_SUBLINK,
	EXPR_SUBLINK,
	ARRAY_SUBLINK,
	NOT_EXISTS_SUBLINK
} SubLinkType;

typedef struct SubLink
{
	Expr		xpr;
	SubLinkType subLinkType;	/* see above */
	Node	   *testexpr;		/* outer-query test for ALL/ANY/ROWCOMPARE */
	List	   *operName;		/* originally specified operator name */
	Node	   *subselect;		/* subselect as Query* or parsetree */
	int			location;		/* token location, or -1 if unknown */
} SubLink;

/*
 * SubPlan - executable expression node for a subplan (sub-SELECT)
 *
 * The planner replaces SubLink nodes in expression trees with SubPlan
 * nodes after it has finished planning the subquery.  SubPlan references
 * a sub-plantree stored in the subplans list of the toplevel PlannedStmt.
 * (We avoid a direct link to make it easier to copy expression trees
 * without causing multiple processing of the subplan.)
 *
 * In an ordinary subplan, testexpr points to an executable expression
 * (OpExpr, an AND/OR tree of OpExprs, or RowCompareExpr) for the combining
 * operator(s); the left-hand arguments are the original lefthand expressions,
 * and the right-hand arguments are PARAM_EXEC Param nodes representing the
 * outputs of the sub-select.  (NOTE: runtime coercion functions may be
 * inserted as well.)  This is just the same expression tree as testexpr in
 * the original SubLink node, but the PARAM_SUBLINK nodes are replaced by
 * suitably numbered PARAM_EXEC nodes.
 *
 * If the sub-select becomes an initplan rather than a subplan, the executable
 * expression is part of the outer plan's expression tree (and the SubPlan
 * node itself is not).  In this case testexpr is NULL to avoid duplication.
 *
 * The planner also derives lists of the values that need to be passed into
 * and out of the subplan.	Input values are represented as a list "args" of
 * expressions to be evaluated in the outer-query context (currently these
 * args are always just Vars, but in principle they could be any expression).
 * The values are assigned to the global PARAM_EXEC params indexed by parParam
 * (the parParam and args lists must have the same ordering).  setParam is a
 * list of the PARAM_EXEC params that are computed by the sub-select, if it
 * is an initplan; they are listed in order by sub-select output column
 * position.  (parParam and setParam are integer Lists, not Bitmapsets,
 * because their ordering is significant.)
 */
typedef struct SubPlan
{
	Expr		xpr;
	/* Fields copied from original SubLink: */
	SubLinkType subLinkType;	/* see above */
	/* The combining operators, transformed to an executable expression: */
	Node	   *testexpr;		/* OpExpr or RowCompareExpr expression tree */
 	List	   *paramIds;		/* IDs of Params embedded in the above */

    int         qDispSliceId;   /* CDB: slice# of initplan's root slice, or 0 */

	/* The subselect, transformed to a Plan: */

	/* Identification of the Plan tree to use: */
	int			plan_id;		/* Index (from 1) in PlannedStmt.subplans */
	/* Identification of the SubPlan for EXPLAIN and debugging purposes: */
	char	   *plan_name;		/* A name assigned during planning */

	/* Extra data useful for determining subplan's output type: */
	Oid			firstColType;	/* Type of first column of subplan result */
	int32		firstColTypmod;	/* Typmod of first column of subplan result */
	/* Information about execution strategy: */
	bool		useHashTable;	/* TRUE to store subselect output in a hash
								 * table (implies we are doing "IN") */
	bool		unknownEqFalse; /* TRUE if it's okay to return FALSE when the
								 * spec result is UNKNOWN; this allows much
								 * simpler handling of null values */
	bool		is_initplan;	/* CDB: Is the subplan implemented as an
								 * initplan? */
	bool		is_multirow;	/* CDB: May the subplan return more than
								 * one row? */
	bool		is_parallelized; /* Has subplan been processed to be executed in parallel setting */
	/* Information for passing params into and out of the subselect: */
	/* setParam and parParam are lists of integers (param IDs) */
	List	   *setParam;		/* initplan subqueries have to set these
								 * Params for parent plan */
	List	   *parParam;		/* indices of input Params from parent plan */
	List	   *args;			/* exprs to pass as parParam values */
} SubPlan;

/* ----------------
 * FieldSelect
 *
 * FieldSelect represents the operation of extracting one field from a tuple
 * value.  At runtime, the input expression is expected to yield a rowtype
 * Datum.  The specified field number is extracted and returned as a Datum.
 * ----------------
 */

typedef struct FieldSelect
{
	Expr		xpr;
	Expr	   *arg;			/* input expression */
	AttrNumber	fieldnum;		/* attribute number of field to extract */
	Oid			resulttype;		/* type of the field (result type of this
								 * node) */
	int32		resulttypmod;	/* output typmod (usually -1) */
} FieldSelect;

/* ----------------
 * FieldStore
 *
 * FieldStore represents the operation of modifying one field in a tuple
 * value, yielding a new tuple value (the input is not touched!).  Like
 * the assign case of ArrayRef, this is used to implement UPDATE of a
 * portion of a column.
 *
 * A single FieldStore can actually represent updates of several different
 * fields.	The parser only generates FieldStores with single-element lists,
 * but the planner will collapse multiple updates of the same base column
 * into one FieldStore.
 * ----------------
 */

typedef struct FieldStore
{
	Expr		xpr;
	Expr	   *arg;			/* input tuple value */
	List	   *newvals;		/* new value(s) for field(s) */
	List	   *fieldnums;		/* integer list of field attnums */
	Oid			resulttype;		/* type of result (same as type of arg) */
	/* Like RowExpr, we deliberately omit a typmod here */
} FieldStore;

/* ----------------
 * RelabelType
 *
 * RelabelType represents a "dummy" type coercion between two binary-
 * compatible datatypes, such as reinterpreting the result of an OID
 * expression as an int4.  It is a no-op at runtime; we only need it
 * to provide a place to store the correct type to be attributed to
 * the expression result during type resolution.  (We can't get away
 * with just overwriting the type field of the input expression node,
 * so we need a separate node to show the coercion's result type.)
 * ----------------
 */

typedef struct RelabelType
{
	Expr		xpr;
	Expr	   *arg;			/* input expression */
	Oid			resulttype;		/* output type of coercion expression */
	int32		resulttypmod;	/* output typmod (usually -1) */
	CoercionForm relabelformat; /* how to display this node */
	int			location;		/* token location, or -1 if unknown */
} RelabelType;

/* ----------------
 * ConvertRowtypeExpr
 *
 * ConvertRowtypeExpr represents a type coercion from one composite type
 * to another, where the source type is guaranteed to contain all the columns
 * needed for the destination type plus possibly others; the columns need not
 * be in the same positions, but are matched up by name.  This is primarily
 * used to convert a whole-row value of an inheritance child table into a
 * valid whole-row value of its parent table's rowtype.
 * ----------------
 */

typedef struct ConvertRowtypeExpr
{
	Expr		xpr;
	Expr	   *arg;			/* input expression */
	Oid			resulttype;		/* output type (always a composite type) */
	/* result typmod is not stored, but must be -1; see RowExpr comments */
	CoercionForm convertformat; /* how to display this node */
	int			location;		/* token location, or -1 if unknown */
} ConvertRowtypeExpr;

/*----------
 * CaseExpr - a CASE expression
 *
 * We support two distinct forms of CASE expression:
 *		CASE WHEN boolexpr THEN expr [ WHEN boolexpr THEN expr ... ]
 *		CASE testexpr WHEN compexpr THEN expr [ WHEN compexpr THEN expr ... ]
 * These are distinguishable by the "arg" field being NULL in the first case
 * and the testexpr in the second case.
 *
 * In the raw grammar output for the second form, the condition expressions
 * of the WHEN clauses are just the comparison values.	Parse analysis
 * converts these to valid boolean expressions of the form
 *		CaseTestExpr '=' compexpr
 * where the CaseTestExpr node is a placeholder that emits the correct
 * value at runtime.  This structure is used so that the testexpr need be
 * evaluated only once.  Note that after parse analysis, the condition
 * expressions always yield boolean.
 *
 * Note: we can test whether a CaseExpr has been through parse analysis
 * yet by checking whether casetype is InvalidOid or not.
 *----------
 */
typedef struct CaseExpr
{
	Expr		xpr;
	Oid			casetype;		/* type of expression result */
	Expr	   *arg;			/* implicit equality comparison argument */
	List	   *args;			/* the arguments (list of WHEN clauses) */
	Expr	   *defresult;		/* the default result (ELSE clause) */
	int			location;		/* token location, or -1 if unknown */
} CaseExpr;

/*
 * CaseWhen - one arm of a CASE expression
 */
typedef struct CaseWhen
{
	Expr		xpr;
	Expr	   *expr;			/* condition expression */
	Expr	   *result;			/* substitution result */
	int			location;		/* token location, or -1 if unknown */
} CaseWhen;

/*
 * Placeholder node for the test value to be processed by a CASE expression.
 * This is effectively like a Param, but can be implemented more simply
 * since we need only one replacement value at a time.
 *
 * We also use this in nested UPDATE expressions.
 * See transformAssignmentIndirection().
 */
typedef struct CaseTestExpr
{
	Expr		xpr;
	Oid			typeId;			/* type for substituted value */
	int32		typeMod;		/* typemod for substituted value */
} CaseTestExpr;

/*
 * ArrayExpr - an ARRAY[] expression
 *
 * Note: if multidims is false, the constituent expressions all yield the
 * scalar type identified by element_typeid.  If multidims is true, the
 * constituent expressions all yield arrays of element_typeid (ie, the same
 * type as array_typeid); at runtime we must check for compatible subscripts.
 */
typedef struct ArrayExpr
{
	Expr		xpr;
	Oid			array_typeid;	/* type of expression result */
	Oid			element_typeid; /* common type of array elements */
	List	   *elements;		/* the array elements or sub-arrays */
	bool		multidims;		/* true if elements are sub-arrays */
	int			location;		/* token location, or -1 if unknown */
} ArrayExpr;

/*
 * RowExpr - a ROW() expression
 *
 * Note: the list of fields must have a one-for-one correspondence with
 * physical fields of the associated rowtype, although it is okay for it
 * to be shorter than the rowtype.	That is, the N'th list element must
 * match up with the N'th physical field.  When the N'th physical field
 * is a dropped column (attisdropped) then the N'th list element can just
 * be a NULL constant.	(This case can only occur for named composite types,
 * not RECORD types, since those are built from the RowExpr itself rather
 * than vice versa.)  It is important not to assume that length(args) is
 * the same as the number of columns logically present in the rowtype.
 *
 * colnames is NIL in a RowExpr built from an ordinary ROW() expression.
 * It is provided in cases where we expand a whole-row Var into a RowExpr,
 * to retain the column alias names of the RTE that the Var referenced
 * (which would otherwise be very difficult to extract from the parsetree).
 * Like the args list, it is one-for-one with physical fields of the rowtype.
 */
typedef struct RowExpr
{
	Expr		xpr;
	List	   *args;			/* the fields */
	Oid			row_typeid;		/* RECORDOID or a composite type's ID */

	/*
	 * Note: we deliberately do NOT store a typmod.  Although a typmod will be
	 * associated with specific RECORD types at runtime, it will differ for
	 * different backends, and so cannot safely be stored in stored
	 * parsetrees.	We must assume typmod -1 for a RowExpr node.
	 */
	CoercionForm row_format;	/* how to display this node */
	List	   *colnames;		/* list of String, or NIL */
	int			location;		/* token location, or -1 if unknown */
} RowExpr;

/*
 * RowCompareExpr - row-wise comparison, such as (a, b) <= (1, 2)
 *
 * We support row comparison for any operator that can be determined to
 * act like =, <>, <, <=, >, or >= (we determine this by looking for the
 * operator in btree opclasses).  Note that the same operator name might
 * map to a different operator for each pair of row elements, since the
 * element datatypes can vary.
 *
 * A RowCompareExpr node is only generated for the < <= > >= cases;
 * the = and <> cases are translated to simple AND or OR combinations
 * of the pairwise comparisons.  However, we include = and <> in the
 * RowCompareType enum for the convenience of parser logic.
 */
typedef enum RowCompareType
{
	/* Values of this enum are chosen to match btree strategy numbers */
	ROWCOMPARE_LT = 1,			/* BTLessStrategyNumber */
	ROWCOMPARE_LE = 2,			/* BTLessEqualStrategyNumber */
	ROWCOMPARE_EQ = 3,			/* BTEqualStrategyNumber */
	ROWCOMPARE_GE = 4,			/* BTGreaterEqualStrategyNumber */
	ROWCOMPARE_GT = 5,			/* BTGreaterStrategyNumber */
	ROWCOMPARE_NE = 6			/* no such btree strategy */
} RowCompareType;

typedef struct RowCompareExpr
{
	Expr		xpr;
	RowCompareType rctype;		/* LT LE GE or GT, never EQ or NE */
	List	   *opnos;			/* OID list of pairwise comparison ops */
	List	   *opclasses;		/* OID list of containing operator classes */
	List	   *largs;			/* the left-hand input arguments */
	List	   *rargs;			/* the right-hand input arguments */
} RowCompareExpr;

/*
 * CoalesceExpr - a COALESCE expression
 */
typedef struct CoalesceExpr
{
	Expr		xpr;
	Oid			coalescetype;	/* type of expression result */
	List	   *args;			/* the arguments */
	int			location;		/* token location, or -1 if unknown */
} CoalesceExpr;

/*
 * MinMaxExpr - a GREATEST or LEAST function
 */
typedef enum MinMaxOp
{
	IS_GREATEST,
	IS_LEAST
} MinMaxOp;

typedef struct MinMaxExpr
{
	Expr		xpr;
	Oid			minmaxtype;		/* common type of arguments and result */
	MinMaxOp	op;				/* function to execute */
	List	   *args;			/* the arguments */
	int			location;		/* token location, or -1 if unknown */
} MinMaxExpr;

/*
 * NullIfExpr - a NULLIF expression
 *
 * Like DistinctExpr, this is represented the same as an OpExpr referencing
 * the "=" operator for x and y.
 */
typedef OpExpr NullIfExpr;

/* ----------------
 * NullTest
 *
 * NullTest represents the operation of testing a value for NULLness.
 * The appropriate test is performed and returned as a boolean Datum.
 *
 * NOTE: the semantics of this for rowtype inputs are noticeably different
 * from the scalar case.  It would probably be a good idea to include an
 * "argisrow" flag in the struct to reflect that, but for the moment,
 * we do not do so to avoid forcing an initdb during 8.2beta.
 * ----------------
 */

typedef enum NullTestType
{
	IS_NULL, IS_NOT_NULL
} NullTestType;

typedef struct NullTest
{
	Expr		xpr;
	Expr	   *arg;			/* input expression */
	NullTestType nulltesttype;	/* IS NULL, IS NOT NULL */
} NullTest;

/*
 * BooleanTest
 *
 * BooleanTest represents the operation of determining whether a boolean
 * is TRUE, FALSE, or UNKNOWN (ie, NULL).  All six meaningful combinations
 * are supported.  Note that a NULL input does *not* cause a NULL result.
 * The appropriate test is performed and returned as a boolean Datum.
 */

typedef enum BoolTestType
{
	IS_TRUE, IS_NOT_TRUE, IS_FALSE, IS_NOT_FALSE, IS_UNKNOWN, IS_NOT_UNKNOWN
} BoolTestType;

typedef struct BooleanTest
{
	Expr		xpr;
	Expr	   *arg;			/* input expression */
	BoolTestType booltesttype;	/* test type */
} BooleanTest;

/*
 * CoerceToDomain
 *
 * CoerceToDomain represents the operation of coercing a value to a domain
 * type.  At runtime (and not before) the precise set of constraints to be
 * checked will be determined.	If the value passes, it is returned as the
 * result; if not, an error is raised.	Note that this is equivalent to
 * RelabelType in the scenario where no constraints are applied.
 */
typedef struct CoerceToDomain
{
	Expr		xpr;
	Expr	   *arg;			/* input expression */
	Oid			resulttype;		/* domain type ID (result type) */
	int32		resulttypmod;	/* output typmod (currently always -1) */
	CoercionForm coercionformat;	/* how to display this node */
	int			location;		/* token location, or -1 if unknown */
} CoerceToDomain;

/*
 * Placeholder node for the value to be processed by a domain's check
 * constraint.	This is effectively like a Param, but can be implemented more
 * simply since we need only one replacement value at a time.
 *
 * Note: the typeId/typeMod will be set from the domain's base type, not
 * the domain itself.  This is because we shouldn't consider the value to
 * be a member of the domain if we haven't yet checked its constraints.
 */
typedef struct CoerceToDomainValue
{
	Expr		xpr;
	Oid			typeId;			/* type for substituted value */
	int32		typeMod;		/* typemod for substituted value */
	int			location;		/* token location, or -1 if unknown */
} CoerceToDomainValue;

/*
 * Placeholder node for a DEFAULT marker in an INSERT or UPDATE command.
 *
 * This is not an executable expression: it must be replaced by the actual
 * column default expression during rewriting.	But it is convenient to
 * treat it as an expression node during parsing and rewriting.
 */
typedef struct SetToDefault
{
	Expr		xpr;
	Oid			typeId;			/* type for substituted value */
	int32		typeMod;		/* typemod for substituted value */
	int			location;		/* token location, or -1 if unknown */
} SetToDefault;

/*
 * Node representing [WHERE] CURRENT OF cursor_name
 *
 * CURRENT OF is a bit like a Var, in that it carries the rangetable index
 * of the target relation being constrained; this aids placing the expression
 * correctly during planning.  We can assume however that its "levelsup" is
 * always zero, due to the syntactic constraints on where it can appear.
 *
 * CURRENT OF is a bit like a stable function, in that it must be evaluated
 * once during constant folding to give the QEs a consistent view of the query.
 * To accomplish this, during constant folding, we evaluate the CURRENT OF
 * expression into constant values of gp_segment_id, ctid, and tableoid; then,
 * we bind these constant values into the CurrentOfExpr here for consumption
 * by the QEs.
 */
typedef struct CurrentOfExpr
{
	Expr    		xpr;
	char     		*cursor_name;  	/* name of referenced cursor */
	/* for planning */
	Index    		cvarno;      	/* RT index of target relation */
	/* for validation */
	Oid				target_relid;	/* OID of original target relation,
									 * before any inheritance expansion */
	/* for constant folding */
	int		 		gp_segment_id;
	ItemPointerData	ctid;
	Oid				tableoid;
} CurrentOfExpr;

/*--------------------
 * TargetEntry -
 *	   a target entry (used in query target lists)
 *
 * Strictly speaking, a TargetEntry isn't an expression node (since it can't
 * be evaluated by ExecEvalExpr).  But we treat it as one anyway, since in
 * very many places it's convenient to process a whole query targetlist as a
 * single expression tree.
 *
 * In a SELECT's targetlist, resno should always be equal to the item's
 * ordinal position (counting from 1).	However, in an INSERT or UPDATE
 * targetlist, resno represents the attribute number of the destination
 * column for the item; so there may be missing or out-of-order resnos.
 * It is even legal to have duplicated resnos; consider
 *		UPDATE table SET arraycol[1] = ..., arraycol[2] = ..., ...
 * The two meanings come together in the executor, because the planner
 * transforms INSERT/UPDATE tlists into a normalized form with exactly
 * one entry for each column of the destination table.	Before that's
 * happened, however, it is risky to assume that resno == position.
 * Generally get_tle_by_resno() should be used rather than list_nth()
 * to fetch tlist entries by resno, and only in SELECT should you assume
 * that resno is a unique identifier.
 *
 * resname is required to represent the correct column name in non-resjunk
 * entries of top-level SELECT targetlists, since it will be used as the
 * column title sent to the frontend.  In most other contexts it is only
 * a debugging aid, and may be wrong or even NULL.	(In particular, it may
 * be wrong in a tlist from a stored rule, if the referenced column has been
 * renamed by ALTER TABLE since the rule was made.	Also, the planner tends
 * to store NULL rather than look up a valid name for tlist entries in
 * non-toplevel plan nodes.)  In resjunk entries, resname should be either
 * a specific system-generated name (such as "ctid") or NULL; anything else
 * risks confusing ExecGetJunkAttribute!
 *
 * ressortgroupref is used in the representation of ORDER BY, GROUP BY, and
 * DISTINCT items.	Targetlist entries with ressortgroupref=0 are not
 * sort/group items.  If ressortgroupref>0, then this item is an ORDER BY,
 * GROUP BY, and/or DISTINCT target value.	No two entries in a targetlist
 * may have the same nonzero ressortgroupref --- but there is no particular
 * meaning to the nonzero values, except as tags.  (For example, one must
 * not assume that lower ressortgroupref means a more significant sort key.)
 * The order of the associated SortGroupClause lists determine the semantics.
 *
 * resorigtbl/resorigcol identify the source of the column, if it is a
 * simple reference to a column of a base table (or view).	If it is not
 * a simple reference, these fields are zeroes.
 *
 * If resjunk is true then the column is a working column (such as a sort key)
 * that should be removed from the final output of the query.  Resjunk columns
 * must have resnos that cannot duplicate any regular column's resno.  Also
 * note that there are places that assume resjunk columns come after non-junk
 * columns.
 *--------------------
 */
typedef struct TargetEntry
{
	Expr		xpr;
	Expr	   *expr;			/* expression to evaluate */
	AttrNumber	resno;			/* attribute number (see notes above) */
	char	   *resname;		/* name of the column (could be NULL) */
	Index		ressortgroupref;/* nonzero if referenced by a sort/group
								 * clause */
	Oid			resorigtbl;		/* OID of column's source table */
	AttrNumber	resorigcol;		/* column's number in source table */
	bool		resjunk;		/* set to true to eliminate the attribute from
								 * final target list */
} TargetEntry;

/* ----------------------------------------------------------------
 *					node types for join trees
 *
 * The leaves of a join tree structure are RangeTblRef nodes.  Above
 * these, JoinExpr nodes can appear to denote a specific kind of join
 * or qualified join.  Also, FromExpr nodes can appear to denote an
 * ordinary cross-product join ("FROM foo, bar, baz WHERE ...").
 * FromExpr is like a JoinExpr of jointype JOIN_INNER, except that it
 * may have any number of child nodes, not just two.
 *
 * NOTE: the top level of a Query's jointree is always a FromExpr.
 * Even if the jointree contains no rels, there will be a FromExpr.
 *
 * NOTE: the qualification expressions present in JoinExpr nodes are
 * *in addition to* the query's main WHERE clause, which appears as the
 * qual of the top-level FromExpr.	The reason for associating quals with
 * specific nodes in the jointree is that the position of a qual is critical
 * when outer joins are present.  (If we enforce a qual too soon or too late,
 * that may cause the outer join to produce the wrong set of NULL-extended
 * rows.)  If all joins are inner joins then all the qual positions are
 * semantically interchangeable.
 *
 * NOTE: in the raw output of gram.y, a join tree contains RangeVar,
 * RangeSubselect, and RangeFunction nodes, which are all replaced by
 * RangeTblRef nodes during the parse analysis phase.  Also, the top-level
 * FromExpr is added during parse analysis; the grammar regards FROM and
 * WHERE as separate.
 * ----------------------------------------------------------------
 */

/*
 * RangeTblRef - reference to an entry in the query's rangetable
 *
 * We could use direct pointers to the RT entries and skip having these
 * nodes, but multiple pointers to the same node in a querytree cause
 * lots of headaches, so it seems better to store an index into the RT.
 */
typedef struct RangeTblRef
{
	NodeTag		type;
	int			rtindex;
} RangeTblRef;

/*----------
 * JoinExpr - for SQL JOIN expressions
 *
 * isNatural, using, and quals are interdependent.	The user can write only
 * one of NATURAL, USING(), or ON() (this is enforced by the grammar).
 * If he writes NATURAL then parse analysis generates the equivalent USING()
 * list, and from that fills in "quals" with the right equality comparisons.
 * If he writes USING() then "quals" is filled with equality comparisons.
 * If he writes ON() then only "quals" is set.	Note that NATURAL/USING
 * are not equivalent to ON() since they also affect the output column list.
 *
 * alias is an Alias node representing the AS alias-clause attached to the
 * join expression, or NULL if no clause.  NB: presence or absence of the
 * alias has a critical impact on semantics, because a join with an alias
 * restricts visibility of the tables/columns inside it.
 *
 * During parse analysis, an RTE is created for the Join, and its index
 * is filled into rtindex.	This RTE is present mainly so that Vars can
 * be created that refer to the outputs of the join.  The planner sometimes
 * generates JoinExprs internally; these can have rtindex = 0 if there are
 * no join alias variables referencing such joins.
 *
 * CDB: When the planner flattens sublinks in the JOIN...ON clause, it may
 * attach a list of RangeTblRef nodes ('subqfromlist') which are to be
 * included in the cross product along with 'larg' and 'rarg'.
 *----------
 */
typedef struct JoinExpr
{
	NodeTag		type;
	JoinType	jointype;		/* type of join */
	bool		isNatural;		/* Natural join? Will need to shape table */
	Node	   *larg;			/* left subtree */
	Node	   *rarg;			/* right subtree */
	List	   *usingClause;	/* USING clause, if any (list of String) */
	Node	   *quals;			/* qualifiers on join, if any */
	Alias	   *alias;			/* user-written alias clause, if any */
	int			rtindex;		/* RT index assigned for join */
    List       *subqfromlist;   /* CDB: List of join subtrees resulting from
                                 *  flattening of sublinks */
} JoinExpr;

/*----------
 * FromExpr - represents a FROM ... WHERE ... construct
 *
 * This is both more flexible than a JoinExpr (it can have any number of
 * children, including zero) and less so --- we don't need to deal with
 * aliases and so on.  The output column set is implicitly just the union
 * of the outputs of the children.
 *----------
 */
typedef struct FromExpr
{
	NodeTag		type;
	List	   *fromlist;		/* List of join subtrees */
	Node	   *quals;			/* qualifiers on join, if any */
} FromExpr;

typedef enum Movement
{
	MOVEMENT_NONE,			/* No motion required. */
	MOVEMENT_FOCUS,			/* Fixed motion to a single segment. */
	MOVEMENT_BROADCAST,		/* Broadcast motion. */
	MOVEMENT_REPARTITION,	/* Hash motion */
	MOVEMENT_LIM_RESTRUCT,	/* Restructure a Limit node into three stages */
	MOVEMENT_EXPLICIT		/* Move tuples to the segments specified in the segid column */
} Movement;

/*----------
 * Flow - describes a tuple flow in a parallelized plan
 *
 * This node type is a MPP extension.
 *
 * Plan nodes contain a reference to a Flow that characterizes the output
 * tuple flow of the node.  In addition, the node contains fields used for
 * parallelizing specification.
 *----------
 */
typedef struct Flow
{
	NodeTag		type;			/* T_Flow */
	FlowType	flotype;		/* Type of flow produced by the plan. */

	/* What motion (including none) should be applied to this Plan's output. */
	Movement	req_move;

	/* Locus type (optimizer flow characterization).
	 */
	CdbLocusType	locustype;

	/* If flotype is FLOW_SINGLETON, then this is the segment (-1 for entry)
	 * on which tuples occur.  If req_move is MOVEMENT_FOCUS, then this is
	 * the desired segment for the resulting singleton flow.
	 */
	int			segindex;		/* Segment index of singleton flow. */

	/* Sort specifications. */
	int			numSortCols;		/* number of sort key columns */
	AttrNumber	*sortColIdx;		/* their indexes in target list */
	Oid			*sortOperators;		/* OID of operators to sort them by */

	/* If req_move is MOVEMENT_REPARTITION, these express the desired
     * partitioning for a hash motion.  Else if flotype is FLOW_PARTITIONED,
     * this is the partitioning key.  Otherwise NIL.
	 * otherwise, they are NIL. */
	List       *hashExpr;			/* list of hash expressions */

	/* If req_move is MOVEMENT_EXPLICIT, this contains the index of the segid column
	 * to use in the motion	 */
	AttrNumber segidColIdx;

    /* The original Flow ptr is saved here upon setting req_move. */
    struct Flow    *flow_before_req_move;

} Flow;

typedef enum GroupingType
{
	GROUPINGTYPE_ROLLUP,         /* ROLLUP grouping extension */
	GROUPINGTYPE_CUBE,           /* CUBE grouping extension */
	GROUPINGTYPE_GROUPING_SETS   /* GROUPING SETS grouping extension */
} GroupingType;

typedef enum WindowExclusion
{
	WINDOW_EXCLUSION_NULL = 0,
	WINDOW_EXCLUSION_CUR_ROW, /* exclude current row */
	WINDOW_EXCLUSION_GROUP, /* exclude rows matching us */
	WINDOW_EXCLUSION_TIES, /* exclude rows matching us, and current row */
	WINDOW_EXCLUSION_NO_OTHERS /* don't exclude -- distinct from EMPTY so
								* that we may dump */
} WindowExclusion;

typedef enum WindowBoundingKind
{
	WINDOW_UNBOUND_PRECEDING,
	WINDOW_BOUND_PRECEDING,
	WINDOW_CURRENT_ROW,
	WINDOW_BOUND_FOLLOWING,
	WINDOW_UNBOUND_FOLLOWING,
	WINDOW_DELAYED_BOUND_PRECEDING,
    WINDOW_DELAYED_BOUND_FOLLOWING
} WindowBoundingKind;

typedef struct WindowFrameEdge
{
	NodeTag type;
	WindowBoundingKind kind;
	/* XXX: need to restrict to certain datatypes in order by */
	Node *val; /* an actual value, if provided */
} WindowFrameEdge;

typedef struct WindowFrame
{
	NodeTag type;
	bool is_rows;	/* true if ROWS was specificied, false if RANGE */
	bool is_between; /* user specified BETWEEN */

	/*
	 * XXX: determine if trail and lead must be mentioned in that order
	 */
	WindowFrameEdge *trail; /* trailing edge of the frame */
	WindowFrameEdge *lead; /* leading edge of the frame */
	WindowExclusion exclude; /* exclusion clause */
	bool system_generated; /* frame was generated by the parser */
} WindowFrame;

/* ---------------
 * WindowKey is an auxiliary node of the Window node (a Plan node).  It
 * represents one level of the potentially multi-level ordering key of
 * the Window node.  The ORDER BY key of the Nth WindowKey of a Window
 * is the concatenation of the sort keys from WindowKeys 0 thru N.
 *
 * Note that, since a window key represents partial sort key, it may be
 * empty.  For example (ORDER BY a,b ROWS x) and (ORDER BY a,b ROWS y)
 * would be represented by partial key (a,b) with framing ROWS x followed
 * by partial key () with framing ROWS y.
 * ---------------
 */
typedef struct WindowKey
{
	NodeTag			type;
	int				numSortCols; /* may be zero, see note */
	AttrNumber	   *sortColIdx;
	Oid			   *sortOperators;
	WindowFrame	   *frame;		/* NULL or framing for WindowKey */
} WindowKey;

/*
 * PercKind
 * Represent function type of PercentileExpr
 */
typedef enum PercKind
{
	PERC_MEDIAN,
	PERC_CONT,
	PERC_DISC
} PercKind;

/*
 * PercentileExpr
 *
 * This represents expressions for percentile_cont, percentile_disc and median.
 * They could be expressed as normal Aggref, but at present we are not able
 * to change the catalog, so we introduce this dedicated node.  As such, the node
 * is treated as Aggref in any cases.  Since we don't support Var in its
 * argument, we don't need var-level field here.
 */
typedef struct PercentileExpr
{
	NodeTag			type;
	Oid				perctype;		/* result type */
	List		   *args;			/* list of argument expression */
	PercKind		perckind;		/* type of percentile function */
	List		   *sortClause;		/* ORDER BY clause */
	List		   *sortTargets;	/* target list for ORDER BY clause */
	Expr		   *pcExpr;			/* peer count expression */
	Expr		   *tcExpr;			/* total count expression */
	int				location;		/* token location, or -1 if unknown */
} PercentileExpr;

/*
 * DMLActionExpr
 *
 * Represents the expression which introduces the action in a SplitUpdate statement
 */
typedef struct DMLActionExpr
{
	Expr        xpr;
} DMLActionExpr;

/*
 * PartOidExpr
 * Represents the expression which holds a part oid in a PartitionSelector operator
 */
typedef struct PartOidExpr
{
	Expr		xpr;
	int 		level;			/* partitioning level */
} PartOidExpr;

/*
 * PartDefaultExpr
 * Represents the expression which determines whether this a part is a default part
 */
typedef struct PartDefaultExpr
{
	Expr		xpr;
	int 		level;			/* partitioning level */
} PartDefaultExpr;

/*
 * PartBoundExpr
 * Represents the expression which holds a part boundary in a PartitionSelector operator
 */
typedef struct PartBoundExpr
{
	Expr		xpr;
	int 		level;			/* partitioning level */
	Oid 		boundType;		/* the return type of this boundary - same as part key */
	bool 		isLowerBound;	/* lower (min) or upper (max) bound */
} PartBoundExpr;

/*
 * PartBoundInclusionExpr
 * Represents the expression which determines whether a part boundary is inclusive or not
 * in a PartitionSelector operator
 */
typedef struct PartBoundInclusionExpr
{
	Expr		xpr;
	int			level;			/* partitioning level */
	bool		isLowerBound;	/* lower (min) or upper (max) bound */
} PartBoundInclusionExpr;

/*
 * PartBoundOpenExpr
 * Represents the expression which determines whether a part boundary is open (unbounded) or not
 * in a PartitionSelector operator
 */
typedef struct PartBoundOpenExpr
{
	Expr		xpr;
	int			level;			/* partitioning level */
	bool		isLowerBound;	/* lower (min) or upper (max) bound */
} PartBoundOpenExpr;

#endif   /* PRIMNODES_H */

redpajama_set_name: RedPajamaGithub


text:
package br.com.autonomiccs.autonomic.algorithms.commons.services;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
import org.apache.cloudstack.framework.config.impl.ConfigurationVO;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InOrder;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;

import com.cloud.host.HostVO;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.service.ServiceOfferingVO;
import com.cloud.service.dao.ServiceOfferingDao;
import com.cloud.storage.Storage.ProvisioningType;
import com.cloud.vm.VMInstanceVO;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.dao.VMInstanceDao;

import br.com.autonomiccs.autonomic.algorithms.commons.beans.HostResources;
import br.com.autonomiccs.autonomic.algorithms.commons.beans.VmResources;

@RunWith(MockitoJUnitRunner.class)
public class HostResourcesServiceTest {

    @InjectMocks
    private HostResourcesService hostResourcesService;
    @Mock
    private ServiceOfferingDao serviceOfferingDao;
    @Mock
    private ConfigurationDao configurationDao;
    @Mock
    private VMInstanceDao vmInstanceDao;

    private Random random = new Random();

    private HostResourcesTestUtils hostResourcesUtils = new HostResourcesTestUtils();

    private VMInstanceVO vmInstance;

    @Before
    public void beforeTest() {
        vmInstance = new VMInstanceVO(random.nextLong(), 1l, "name", "instanceName", com.cloud.vm.VirtualMachine.Type.User, 1l, HypervisorType.XenServer, 1l, 1l, 1l,
                1l, true, true, 1l);
    }

    @Test
    public void listVmsFromHostTest() {
        HostResources hostResources = Mockito.mock(HostResources.class);
        Mockito.when(hostResources.getHostId()).thenReturn(1l);

        ServiceOfferingVO serviceOfferingVO = new ServiceOfferingVO("name", 1, 512, 1000, 1000, 1000, true, "displayText", ProvisioningType.THIN, true, true, "tags", true,
                com.cloud.vm.VirtualMachine.Type.User, true);

        List<VMInstanceVO> vmsInstanceVO = createRunningVmIistanceVo(2);
        Mockito.when(vmInstanceDao.listByHostId(1l)).thenReturn(vmsInstanceVO);
        Mockito.when(serviceOfferingDao.findById(1l)).thenReturn(serviceOfferingVO);

        List<VmResources> vmResourcesList = hostResourcesService.listVmsFromHost(hostResources);

        Assert.assertEquals(2, vmResourcesList.size());
        Assert.assertEquals(1000l, vmResourcesList.get(0).getCpuSpeed());
        Assert.assertEquals(512l, vmResourcesList.get(1).getMemoryInMegaBytes());
        Assert.assertEquals(1, vmResourcesList.get(0).getNumberOfCpus());
    }

    @Test
    public void createHostResourcesTest() {
        HostVO hostVo = new HostVO("");
        HostResources host = new HostResources();

        HostResourcesService spy = Mockito.spy(new HostResourcesService());
        Mockito.doReturn(host).when(spy).createAndConfigureHostResources(hostVo);

        List<VmResources> vms = hostResourcesUtils.createSmallVms(1);
        Mockito.doReturn(vms).when(spy).listVmsFromHost(host);

        Mockito.doNothing().when(spy).calculateHostResourcesAllocated(host);
        Mockito.doNothing().when(spy).loadHostOverprovisioningFactors(host);

        HostResources hostResourcesReturned = spy.createHostResources(hostVo);
        Assert.assertEquals(vms, hostResourcesReturned.getVmsResources());

        InOrder inOrder = Mockito.inOrder(spy);
        inOrder.verify(spy).createAndConfigureHostResources(hostVo);
        inOrder.verify(spy).listVmsFromHost(host);
        inOrder.verify(spy).calculateHostResourcesAllocated(host);
        inOrder.verify(spy).loadHostOverprovisioningFactors(host);
    }

    @Test
    public void createAndConfigureHostResourcesTest() {
        HostVO hostVo = Mockito.mock(HostVO.class);
        Mockito.when(hostVo.getId()).thenReturn(1l);
        Mockito.when(hostVo.getName()).thenReturn("test");
        Mockito.when(hostVo.getSpeed()).thenReturn(2000l);
        Mockito.when(hostVo.getCpus()).thenReturn(4);
        Mockito.when(hostVo.getTotalMemory()).thenReturn(8000l);

        HostResources host = hostResourcesService.createAndConfigureHostResources(hostVo);

        Assert.assertEquals(1l, host.getHostId());
        Assert.assertEquals("test", host.getHostName());
        Assert.assertEquals(2000l, host.getSpeed());
        Assert.assertEquals(4, host.getCpus().intValue());
        Assert.assertEquals(8000l, host.getTotalMemoryInBytes());
    }

    @Test
    public void calculateHostResourcesAllocatedTest() {
        HostResources hostResources = new HostResources();
        hostResourcesUtils.createHostWithSmallVms(hostResources, 1);
        hostResourcesService.calculateHostResourcesAllocated(hostResources);

        Assert.assertEquals(512l, hostResources.getUsedMemoryInMegaBytes());
        Assert.assertEquals(1000l, hostResources.getUsedCpu());
    }

    @Test
    public void isVmStateRunningTest() {
        vmInstance.setState(VirtualMachine.State.Running);
        Assert.assertTrue(hostResourcesService.isVmCurrentlyUsingHostResource(vmInstance));
    }

    @Test
    public void isVmStateMigratingTest() {
        vmInstance.setState(VirtualMachine.State.Migrating);
        Assert.assertTrue(hostResourcesService.isVmCurrentlyUsingHostResource(vmInstance));
    }

    @Test
    public void isVmStateStartingTest() {
        vmInstance.setState(VirtualMachine.State.Starting);
        Assert.assertTrue(hostResourcesService.isVmCurrentlyUsingHostResource(vmInstance));
    }

    @Test
    public void isVmStateDestroyedTest() {
        vmInstance.setState(VirtualMachine.State.Destroyed);
        Assert.assertFalse(hostResourcesService.isVmCurrentlyUsingHostResource(vmInstance));
    }

    @Test
    public void isVmStateErrorTest() {
        vmInstance.setState(VirtualMachine.State.Error);
        Assert.assertFalse(hostResourcesService.isVmCurrentlyUsingHostResource(vmInstance));
    }

    @Test
    public void isVmStateExpungingTest() {
        vmInstance.setState(VirtualMachine.State.Expunging);
        Assert.assertFalse(hostResourcesService.isVmCurrentlyUsingHostResource(vmInstance));
    }

    @Test
    public void isVmStateShutdownedTest() {
        vmInstance.setState(VirtualMachine.State.Shutdowned);
        Assert.assertFalse(hostResourcesService.isVmCurrentlyUsingHostResource(vmInstance));
    }

    @Test
    public void isVmStateStoppingTest() {
        vmInstance.setState(VirtualMachine.State.Stopping);
        Assert.assertFalse(hostResourcesService.isVmCurrentlyUsingHostResource(vmInstance));
    }

    @Test
    public void isVmStateUnknownTest() {
        vmInstance.setState(VirtualMachine.State.Unknown);
        Assert.assertFalse(hostResourcesService.isVmCurrentlyUsingHostResource(vmInstance));
    }

    @Test
    public void loadHostOverprovisioningFactorsTest() {
        HostResources hostResources = new HostResources();

        ConfigurationVO configurationVOCpu = Mockito.mock(ConfigurationVO.class);
        ConfigurationVO configurationVOMem = Mockito.mock(ConfigurationVO.class);

        Mockito.when(configurationDao.findByName("cpu.overprovisioning.factor")).thenReturn(configurationVOCpu);
        Mockito.when(configurationVOCpu.getValue()).thenReturn("1.5");

        Mockito.when(configurationDao.findByName("mem.overprovisioning.factor")).thenReturn(configurationVOMem);
        Mockito.when(configurationVOMem.getValue()).thenReturn("2.0");

        hostResourcesService.loadHostOverprovisioningFactors(hostResources);

        Assert.assertEquals(1.5, hostResources.getCpuOverprovisioning(), 0f);
        Assert.assertEquals(2.0, hostResources.getMemoryOverprovisioning(), 0f);
    }

    private List<VMInstanceVO> createRunningVmIistanceVo(int amount) {
        List<VMInstanceVO> vms = new ArrayList<VMInstanceVO>();
        for(int i = 0; i<amount; i++) {
            VMInstanceVO vm = new VMInstanceVO(random.nextLong(), 1l, "name", "instanceName", com.cloud.vm.VirtualMachine.Type.User, 1l, HypervisorType.XenServer, 1l, 1l, 1l, 1l,
                    true, true, 1l);
            vm.setState(VirtualMachine.State.Running);
            vms.add(vm);
        }
        return vms;
    }
}


Ben Hoogendoorn, FH Canada President and CEO, reflects on his visits to Burundi.
How do you break free from a system that reinforces poverty?
In the town of Kayanza in Burundi I observed girls and young women (age 15-25) carrying bricks up a long hill. Each girl balanced 70-80 lbs of weight on their heads as they walked barefoot.
Watching the tiny, measured steps of the girls made it plain to me that these girls were used to these heavy of loads. I never saw one brick dropped or a single stumble as they walked. I'm not sure what kind of damage this is doing to their necks and spines but I'm sure it is significant. I tried lifting a load and was just able to pick it up - it was that heavy.
I asked one of our Food for the Hungry (FH) staff to find out for me how much these women made each day. I was shocked to learn that they are paid by the brick. If they carried a thousand bricks within a day they would make about 80 cents.
That is abuse, pure and simple, but in this country it is normal because without this job, these girls be forced to find more devastating "work" in order to survive. This system, which uses poverty to the advantage of some to get cheap labour, is hard to overcome as it permeates society. Breaking this cycle of severe and chronic poverty is something FH is doing here in Burundi and other countries around the globe.
What is FH doing to break the cycle of poverty?
In Burundi, FH is working at the community level to assist people in working together and helping one another end the poverty that grips their families. FH encourages them to build integrated systems of farming that incorporates new ideas and techniques.
In Burundi this also means protecting the environment and land they are farming. Because the land is very steep, erosion is a huge problem. This not only negatively impacts the hillsides, but during heavy rains the soil and mud from the hills wash down onto the valley below and destroy the crops growing in the fertile valley bottoms as well.
FH has introduced a new type of terracing to Burundi that has been used successfully in Rwanda for many years. This and the introduction of new plant varieties, composting, and the use of animal fertilizer has made a significant difference in the food production. Kitchen gardens and the raising of small animals have also had a positive impact on many families.
While this will not immediately stop young women from having to carry extremely heavy loads on their heads, it is the beginning of building sustainable systems that will further benefit the entire region. Farmers in adjoining communities are already asking our staff when FH can come to their village. We would love to be able to engage with the neighbouring communities and improve their land by showing them new ways of farming and by helping them help themselves.
Empowering them to follow new practices themselves is proven to be a sustainable model. I am so proud of what our field staff has accomplished in such a short period of time.